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 3333354
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T23:47:14+00:00 2026-05-17T23:47:14+00:00

I have a problem due to scopes and the form_for helper in rails 3.

  • 0

I have a problem due to scopes and the form_for helper in rails 3.
The routes – file looks like this:

scope "(/:tab)" do
  resources :article
end

The form looks something like this:

<%= form_for(@article) %>
   <%= f.label :title %>
   <%= f.text_field :title %>
    etc.
<%end%>

The tab – attribute is stored in params[:tab], as a string
My problem is that this genereate wrong urls in the form. How could I get this to work ?
The genreated url article_path(params[:tab], @article) works perfectly fine

  • 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-17T23:47:15+00:00Added an answer on May 17, 2026 at 11:47 pm

    The answer I came up with was quite ugly, but works with both update and create:

    <%= form_for(@article, :url => (@article.new_record? ? 
        articles_path(params[:tab]) : article_path(params[:tab], @article) do |f| %>
    

    Update:
    A better solution would be to override the default_url_options-method to something like this:

    def default_url_options(options={})
      { :tab => params[:tab] }
    end
    

    Then the <%= form_for @article do |f| %> could be used, and all urls are correctly generated

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

Sidebar

Related Questions

I have a ridiculous question due to a ridiculous problem. Normally if I want
I have been having the following problem, i think it's probably due to the
I have problem with Android using the class HttpUrlConnection my method is this: public
I have problem thinking this trough with PHP & Mysql . I have read
I have problem compilin this code..can anyone tell whats wrong with the syntax CREATE
I have a problem due to my terrible math abilities, that I cannot figure
Using MySQL 5 I have a table like this: date (varchar) door (varchar) shift
I have a problem and due to that reason i am working on a
Not sure if this is a problem due to using transparent backgrounds, but I
I have a Problem accessing an Object function using this. In case of the

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.