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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:13:27+00:00 2026-05-23T18:13:27+00:00

I started the question differently, about a collection_select, but I found out that is

  • 0

I started the question differently, about a collection_select, but I found out that is not the problem.
This particular model won’t save any data at all. It just ignores the values in the parameters. I can only save new records with NULL values (except for the timestamp fields).

See my comment for my latest try to fix it.

I have generated a few models with the handy scaffold command. Now I have tried to change a textbox to a collection_select for linking the new entity to the correct related one.

Using rails 3.1RC4 (hopefully this is not a bug).

In the _form.html.erb I use the following code:

    <div class="field">
    <%= f.label :category_id %><br />
    <%= f.collection_select(:category_id, Admin::Category.all, :id, :name) %>
  </div>
  <div class="field">
    <%= f.label :name %><br />
    <%= f.text_field :name %>
  ...all other items...
  <div class="actions">
    <%= f.submit %>
  </div>

After I click the submit button I receive error messages. It says that the name and permalink do not comply to the validation. I don’t understand however, because in the logfiles I find this:

Parameters: {"utf8"=>"✓", "authenticity_token"=>"my token is here", "admin_branche"=>{"category_id"=>"3", "name"=>"Verzekeraars", "permalink"=>"verzekeraars", "visible"=>"1"}, "commit"=>"Create Branche"}

To me it seems that the params contain all the needed values.

For the sake of completeness I will post my create method and model below.

So far I have tried switching back and forth between collection_select and f.coll… with no success. The current setup seems most appropriate to me, based on the logs.
I have also googled a lot, but haven’t been able to find the answer. Question 2280106 on this site looks the same, but it had to do with attr_accessible which I have commented out in the model (I restarted the server afterwards and retried, just to be sure).

Help is much appreciated!

branche.rb:

class Admin::Branche < ActiveRecord::Base

 # attr_accessible :name, :permalink

  #relationships
    has_many :courses, :as => :parent
    belongs_to :category

  #validations
    validates :name, :presence => true, :length => {:maximum => 255}
    validates :permalink, :presence => true, :length => { :within => 4..25 }

end

create action in the controller:

  def create
    @admin_branch = Admin::Branche.new(params[:admin_branch])

    respond_to do |format|
      if @admin_branch.save
        format.html { redirect_to @admin_branch, notice: 'Branche was successfully created.' }
        format.json { render json: @admin_branch, status: :created, location: @admin_branch }
      else
        format.html { render action: "new" }
        format.json { render json: @admin_branch.errors, status: :unprocessable_entity }
      end
    end
  end
  • 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-23T18:13:28+00:00Added an answer on May 23, 2026 at 6:13 pm

    In the controller, you’re doing this:

    @admin_branch = Admin::Branche.new(params[:admin_branch])
    

    You should do this:

    @admin_branch = Admin::Branche.new(params[:admin_branche])
    

    If you look at the request parameters, the attributes are under “admin_branche”, not “admin_branch”.

    I think that should solve your problems, if not, please let us know.

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

Sidebar

Related Questions

Sorry, if this is a noobish question, but I'm just getting started with Rails
This question is motivated by something I've lately started to see a bit too
An answer to a Stack Overflow question stated that a particular framework violated a
This question is about the extent to which it makes sense unit testing. I’ve
I've asked a question like this before but this one is different, this is
I have started a bounty for this question ...because I really want the community's
When answering another question I started to wonder how I could Add new properties
I started off by drafting a question: What is the best way to perform
Just getting started with Linq to SQL so forgive the newbie question. I'm trying
Good morning, Apologies for the newbie question. I'm just getting started with ASP.NET internationalization

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.