Most of my views will required a wrapper of padding 10px,,, but a few will not... I was thinking of doing something like this in the view controller: respond_to do |format| format.html { render :layout => true, :padding => ''false'' } And then in the application.html.erb have an IF to not add a padding class if :padding is false... But the above idea doesn''t work, the variable padding is not being passed. Any ideas? Or cleaner/smart solutions? thxs -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Luke Cowell
2010-Oct-09 01:39 UTC
Re: Rails 3, HowTo - Pass a Setting to the Application.html.erb
Try doing this in your controller: @padding = false Then in your view you can test it like this: <% if @padding %> //do stuff here <% end %> I found it pretty helpful to work through this: http://guides.rubyonrails.org/getting_started.html Luke On 2010-10-08, at 4:48 PM, nobosh wrote:> Most of my views will required a wrapper of padding 10px,,, but a few > will not... > > I was thinking of doing something like this in the view controller: > > > respond_to do |format| > format.html { render :layout => true, :padding => ''false'' } > > And then in the application.html.erb have an IF to not add a padding > class if :padding is false... But the above idea doesn''t work, the > variable padding is not being passed. > > Any ideas? Or cleaner/smart solutions? thxs > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Robert Pankowecki (rupert)
2010-Oct-09 08:32 UTC
Re: Rails 3, HowTo - Pass a Setting to the Application.html.erb
In my opinion you should have 2 layouts. * application, * padding. The `padding'' layout should be nested inside application and (according to its name) add some padding :-). Look here about how to do it in rails 2 and 3: https://rails.lighthouseapp.com/projects/8994/tickets/5305-rails3-rc-named-yield-should-return-nil-when-content_for-with-that-name-was-not-called With that you could setup layout per every action. layout :application layout :padding, :only => [:new]. The second way of doing this: Add one more stylesheet in every view that needs padding: #application.html.erb layout <head> <%= yield :head %> </head> #new.html.erb content_for(:head) do stylesheet_link_tag ''padding'' end You could abstract it into helper method and use as simple as: #new.html.erb <%= padding() %> Third way is to create helper that would be used this way: <%= padding do %> create your content here <% end %> I wouldn''t bother controller with such a minor change in view layer so I prefere keeping padding in views instead changing layout on the controller side. Robert Pankowecki -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
namxam
2010-Oct-09 09:52 UTC
Re: Rails 3, HowTo - Pass a Setting to the Application.html.erb
Or you could add something like <body class="<%= yield(:body_class) %>"> … your stuff </body> and set a conditional css class which can handle the padding. Set the class with content_for() On Oct 9, 10:32 am, "Robert Pankowecki (rupert)" <robert.pankowe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> In my opinion you should have 2 layouts. > * application, > * padding. > > The `padding'' layout should be nested inside application and > (according to its name) add some padding :-). Look here about how to > do it in rails 2 and 3:https://rails.lighthouseapp.com/projects/8994/tickets/5305-rails3-rc-... > > With that you could setup layout per every action. > > layout :application > layout :padding, :only => [:new]. > > The second way of doing this: > > Add one more stylesheet in every view that needs padding: > > #application.html.erb layout > > <head> > <%= yield :head %> > </head> > > #new.html.erb > content_for(:head) do > stylesheet_link_tag ''padding'' > end > > You could abstract it into helper method and use as simple as: > #new.html.erb > <%= padding() %> > > Third way is to create helper that would be used this way: > > <%= padding do %> > create your content here > <% end %> > > I wouldn''t bother controller with such a minor change in view layer so > I prefere keeping padding in views instead changing layout on the > controller side. > > Robert Pankowecki-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 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.