Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1085981
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T22:45:24+00:00 2026-05-16T22:45:24+00:00

Trying to integrate some friendly_id gem functionality on a controller method. Essentially, I have

  • 0

Trying to integrate some friendly_id gem functionality on a controller method.

Essentially, I have a Market object, which has its URL created based on a custom method. Since it’s based on a custom method, friendly_id won’t update the URL when the Market object gets updated. Friendly_id does offer a redo_slugs rake task, but when I call it from within my controller, it tells me that it can’t build the task. Running the command outside works just fine.

The code for my controller looks like this:

require 'rake'
require 'friendly_id'

class Admin::MarketsController < ApplicationController
  def update
    if @market.update_attributes(params[:market])
      rake_market_slugs
    end
  end

  protected
    def rake_market_slugs
      Rake::Task["friendly_id:redo_slugs MODEL=Market"].invoke
    end
end

Am I missing something? Or can I just not do this inside my controller?

Thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T22:45:25+00:00Added an answer on May 16, 2026 at 10:45 pm

    Calling a rake task from a controller to update a model object is terrible. Looking at the code for that rake task, you can see that redo_slugs is simply running the delete_slugs and make_slugs tasks. So there’s another reason not to do this. You’ll be generating slugs for every Market in your table, instead of just the one that you need.

    If you look at the code for make_slugs you can see that there’s no magic there. All it does is load your model objects in blocks of 100 and then save them.

    So, that would be the first thing I would try. Simply reload and save your model. After that, I’d need to see some logs to dig deeper.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to integrate some OpenCV functionality into my application. Currently I have
I'm trying to integrate some drawing functionality into my program. I have a JLabel
I have a large project in C and i'm trying to integrate some Cuda
I'm trying to integrate some photo related functionality with my site and facebook. I
I'm really new to ASP.NET MVC, and I'm trying to integrate some Javascript into
Hi I'm trying to integrate an LDAP search functionality into my app similar to
I am trying to integrate some third party tracking code into one of my
I'm trying to understand how to integrate some quickcheck tests with cabal. This gist
I am trying to integrate some pre-existing code that relies on the com.sun.crypto.provider.SunJCE class
I was wondering if someone could help me. Im trying to integrate some code

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.