Ruby on Rails Monday, August 4, 2014

I want to make a helper for the bootstrap, and for controls (text_field, label ...) I need to use the options of the form_for. There is a form

<%= form_for(@user, url: signup_path, layout: :horizontal) do |user_f| %> <%= user_f.fields_for :person do |person_f| %> <%= person_f.text_field(:last_name) %> <%= person_f.options %> <% end %> <%= user_f.text_field(:last_name) %> <%= user_f.options %> <% end %>

I need to get the value :layout in the control from the form_for I do not understand why <%= user_f.options %> displays:

{:url=>"/signup?locale=ru", :layout=>:horizontal, :html=>{:class=>"new_user", :id=>"new_user", :method=>:post, :authenticity_token=>nil}}

And <%= person_f.options %> displays:

{:builder=>nil, :namespace=>nil, :parent_builder=>#<ActionView::Helpers::FormBuilder:0x007fd338058c60 @nested_child_index={}, @options={:url=>"/signup?locale=ru", :layout=>:horizontal, :html=>{:class=>"new_user", :id=>"new_user", :method=>:post, :authenticity_token=>nil}}, @template=#<#<Class:0x007fd338030738>:0x007fd3375e2268 @_routes=nil, @_config={}, @view_renderer=#<ActionView::Renderer:0x007fd3375e2510 @lookup_context=#<ActionView::LookupContext:0x007fd3375d31a0 @details_key=#<ActionView::LookupContext::DetailsKey:0x007fd3371da5f8 @hash=-3796700121417373084>, @details={:locale=>[:ru], :formats=>[:html], :handlers=>[:erb, :builder, :raw, :ruby, :jbuilder]}, @skip_default_locale=false, @cache=true, @prefixes=["signup", "application"], @rendered_format=:html, @view_paths=#<ActionView::PathSet:0x007fd3375d3970 @paths=[#<ActionView::OptimizedFileSystemResolver:0x007fd33720f3e8 @pattern=":prefix/:action{.:locale,}{.:formats,}{.:handlers,}", @cache=#<ActionView::Resolver::Cache:0x007fd33720f3c0 @data=#<ActionView::Resolver::Cache::SmallCache:0x007fd33720f398 @backend={#<ActionView::LookupContext::DetailsKey:0x007fd3371da5f8 @hash=-3796700121417373084>=>#<ActionView::Resolver::Cache::SmallCache:0x007fd3371d9810 @backend={"new"=>#<ActionView::Resolver::Cache::SmallCache:0x007fd3371d96d0 @backend={"signup"=>#<ActionView::Resolver::Cache::SmallCache:0x007fd3371d9540 @backend={false=>#<ActionView::Resolver::Cache::SmallCache:0x007fd3371d9450 @backend={[]=>[app/views/signup/new.html.erb]}, @default_proc=nil>}, @default_proc=#<Proc:0x007fd33438afe0@/Users/NikolayLipovtsev/.rvm/gems/ruby-2.0.0-p353/gems/actionpack-4.0.2/lib/action_view/template/resolver.rb:45 (lambda)>>}, @default_proc=#<Proc:0x007fd33438afb8@/Users/NikolayLipovtsev/.rvm/gems/ruby-2.0.0-p353/gems/actionpack-4.0.2/lib/action_view/template/resolver.rb:46 (lambda)>>,

...and there is more still large hash. As well that the form options contains much information?

How I can get :layout from person_f and user_f?

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/c4b80f32-f416-4a26-88ac-1d44272ca91e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment