problem with select_tag and observe_field

Hello All,

I have problem with select_tag and observe_field. I get following error

" NoMethodError in Businesses#plan_pricing

Showing app/views/businesses/_refresh_subscription_types.html.haml where line #1 raised:

You have a nil object when you didn't expect it! You might have expected an instance of Array. The error occurred while evaluating nil.collect"

following is source code

Here i get "@subscription_types" object nil , when I render "_plan_pricing.html.haml" first time.

Please tell me where i am doing wrong.

Does the plan_pricing action set @subscription_types to something ?

Fred

Frederick Cheung wrote:

Vikas Gholap wrote:

You're telling it to use the layout called false. If you don't want it to use a layout you need to say :layout => false (ie the value false rather than the string 'false')

Fred

I fixed that syntax error ‘false’ to false but still getting same error

You have a nil object when you didn’t expect it! You might have expected an instance of Array. The error occurred while evaluating nil.collect

for = select_tag ‘subscription’, options_for_select(@subscription_types.collect {|subscription_type| [ subscription_type.title, subscription_type.id ] })

I think this is something to do with brackets and ruby not being able to work out what on earth you’re trying to say.

You have brackets on your inner method, but not your outer method, so ruby requires you put brackets all around everything.

This is, at least, my guess.

Try this:

<%= select_tag(‘subscription’, options_for_select(@subscription_types.collect{|subscription_type| [subscription_type.title, subscription_type.id]})) %>

Julian.

Julian Leviston wrote:

options_for_select(@subscription_types.collect {|subscription_type| [ subscription_type.title, subscription_type.id ] })

I think this is something to do with brackets and ruby not being able to work out what on earth you're trying to say.

You have brackets on your inner method, but not your outer method, so ruby requires you put brackets all around everything.

This is, at least, my guess.

Try this:

<%= select_tag('subscription', options_for_select(@subscription_types.collect{|subscription_type| [subscription_type.title, subscription_type.id]})) %>

Julian.

---------------------------------------------- Learn: http://sensei.zenunit.com/ Last updated 20-May-09 (Rails, Basic Unix) Blog: http://random8.zenunit.com/ Twitter: http://twitter.com/random8r

Hi Julian, I tried that also but getting same error, is there any wrong in my code

I write all my related code here again.