Wednesday, March 7, 2012

[Rails] Re: At least one entry for DB

Thanks for your answer.

I will try after_create.

I have put

after_create :create_first_script

def create_first_script
@video = Video.new(params[:video])
@script = Script.new(:video_id => @video.id, :startp => 0, :text =>
'ToDo: ')
end

in video.rb.
But I need to pass params[:video] somehow...

/videos/_form.html.erb (generated by scaffold) should do it, correct?

<%= form_for(@video) do |f| %>

<div class="field">
<%= f.label :title %><br />
<%= f.text_field :title %>
</div>
<div class="field">
<%= f.label :url %><br />
<%= f.text_field :url %>
</div>
<div class="actions">
<%= f.submit %>
</div>
<% end %>


I am not sure how to pass the video object from here.
Could anyone give me tips?

soichi

--
Posted via http://www.ruby-forum.com/.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate