Database table row creation method

I have following view for user input:

Post new thing

<%= form_tag :action => 'create' %>

Title
<%= text_field 'thing', 'title' %>

Description
<%= text_area 'thing', 'description' %>

Email
<%= text_field 'thing', 'email' %>

<%= submit_tag "Create" %> <%= form_tag %>

… and following controller that populates data (one row) in database

def create
@thing = Thing.new(params[:thing])
end

So far it is working. But I need to add one more parameter to @thing
variable that doesn`t come from user input. It comes from another model
(:another_main_thing_id). What is the syntax for adding this parameter
to @thing variable.
Thank you!

On 8 Mar 2009, at 09:42, Renars Sirotins wrote:

So far it is working. But I need to add one more parameter to @thing
variable that doesn`t come from user input. It comes from another
model
(:another_main_thing_id). What is the syntax for adding this parameter
to @thing variable.

There’s an accessor function created for you for each database
attribute

Fred

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs