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
---------------------------------------------------------------------------------
code for "_plan_pricing.html.haml"
= error_messages_for :business
#plan_picker
- form_for :business, @business, :url =>
polymorphic_path(@business), :html => {:class => 'MainForm'} do |f|
= select_tag 'plan_id',
options_for_select(Plan.find(:all).collect {|plan| [ plan.title, plan.id
] })
= observe_field('plan_id', :url => {:controller => 'users',
:action => :refresh_subscription_types }, :update =>
:refresh_subcription_types, :with => "'plan_id=' + $('plan_id').value")
%span#refresh_subcription_types
= render :partial =>
'businesses/refresh_subscription_types', :layout => 'false'
%p= submit_tag :next_page.l
-------------------------------------------------------------------------------
code for "_refresh_subscription_types.html.haml"
= select_tag 'subscription',
options_for_select(@subscription_types.collect {|subscription_type| [
subscription_type.title, subscription_type.id ] })
--------------------------------------------------------------------------------
code in "controller"
def refresh_subscription_types
@subscription_types = SubscriptionType.find(:all, :conditions =>
{:plan_id => params[:plan_id]})
respond_to do |format|
format.html {
render :partial => 'businesses/refresh_subscription_types',
:layout => 'false'
}
end
end
Here i get "@subscription_types" object nil , when I render
"_plan_pricing.html.haml" first time.
Please tell me where i am doing wrong.
Thanks,
Vikas.
--
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 [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---