question one:
is there any select box tag for form_for?
now,perhaps i just can use the select or select_tag?
question tow:
i have a A model,it has one B such as:
class A< ActiveRecord::Base
belongs_to :B
when i use the form_for tag,how can i output the variable name?like
this:
<%form_for :a,@a,:url=>{:controller=>“a”,:action=>“save”} do |f|%>
<%=f.text_area “b[name]”%>
…
<%end%>
it doesnt work.
thanks for your help!
http://api.rubyonrails.org/ is the best resource for queries like
these. The answer to your question is a yes, just browse through the
documentation to figure it out.
hi,i have the api source,and i have searched it.i have not found the
solution.
pls show me some details,thanks for your help.
thanks!
On Apr 6, 10:25 pm, Frederick C. [email protected]
i wanna set up a blank text area for b.name,i dont wanna display
something.
when i code :
<%fields_for :b,@a.b do |b|%>
there is one error as follows:
You have a nil object when you didn’t expect it!
The error occurred while evaluating nil.b
On Apr 6, 10:25 pm, Frederick C. [email protected]
Does anyone have encountered the problem?
On 6 Apr 2008, at 12:08, Vincent.Z wrote:
question one:
is there any select box tag for form_for?
Like f.select (assuming f is your form builder?)
belongs_to :B
when i use the form_for tag,how can i output the variable name?like
this:
<%form_for :a,@a,:url=>{:controller=>“a”,:action=>“save”} do |f|%>
<%=f.text_area “b[name]”%>
…
<%end%>
You’re trying to display a.b.name ? If so you could either drop down a
level and use text_area_tag, or use fields_for to create a scope
around b (and then you can just do other_f.text_area :name)
Fred
Your @a variable is nil. Make sure that you’re setting it.
Also, I’m not sure if it would mess anything up or not, but naming the
param :b and setting the block variable to |b| might get confusing.
Perhaps you should use something else in the block.
-Kyle
This is not a helpful response whatsoever. People don’t come to post
in Google G. to get pointed to documentation.
Matthew C. wrote:
This is not a helpful response whatsoever. People don’t come to post
in Google G. to get pointed to documentation.
Repeating all that info would degrade this forum. When a newb obviously
does not
know about the /Agile Web/ book, or the online APIs, or how to Google
for our
common FAQs, they need a meta-answer.
–
Phlip
@vincent – I like the api at railsbrain.com It’s the same api info,
just has a little ajax added to it making it easier to search.