How can I have just one layout for all controllers? Ex: Controllers: project_controller todo_controller views/layouts projects.rhtml todos.rhtml --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Mar 7, 2007, at 2:43 PM, Philip Hallstrom wrote:>> How can I have just one layout for all controllers? > > Say you want app/views/layouts/global.rhtml to be your template for > everything... put the following into app/controllers/application.rb: > > layout ''global'' > > Or, if you just want it for some controllers put that layout line > in those > controllers. > >> Ex: >> >> Controllers: >> project_controller >> todo_controller >> >> views/layouts >> projects.rhtml >> todos.rhtmlOr just make a views/layouts/application.rhtml (which will be the default if one named for the controller is not present). Building on what Philip said, you can override the layout for an entire controller or just for a single action with: render :layout => ''global'' -Rob Rob Biedenharn http://agileconsultingllc.com Rob-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> How can I have just one layout for all controllers?Say you want app/views/layouts/global.rhtml to be your template for everything... put the following into app/controllers/application.rb: layout ''global'' Or, if you just want it for some controllers put that layout line in those controllers.> > Ex: > > Controllers: > project_controller > todo_controller > > views/layouts > projects.rhtml > todos.rhtml > > > > >--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Rails will use layouts/application.rhtml as a global layout... no need to configure.... b Philip Hallstrom wrote:>> How can I have just one layout for all controllers? > > Say you want app/views/layouts/global.rhtml to be your template for > everything... put the following into app/controllers/application.rb: > > layout ''global'' > > Or, if you just want it for some controllers put that layout line in those > controllers. > >> Ex: >> >> Controllers: >> project_controller >> todo_controller >> >> views/layouts >> projects.rhtml >> todos.rhtml >> >> > > > >--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
See here http://railscasts.com/episodes/7 seanstewart wrote:> How can I have just one layout for all controllers? > > Ex: > > Controllers: > project_controller > todo_controller > > views/layouts > projects.rhtml > todos.rhtml-- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Howdy, I''ve done a bit of googling but I can''t seem to find something in rails that converts metres to feet the way I need it. Eg, I have a wall height of 1.70 metres, which i convert to 5.5777 feet using: def wall_height_to_ft begin (wall_height.to_f * 3.281).to_s rescue "0" end end So the result I get is really still in metres times by 3.281. The result I need is 5 foot 7 inches or 5''7. Is there a easy way to do this in rails without calculating it myself? Thanks in advance, Chris. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
http://rubyforge.org/projects/units/ On 4/2/07, Chris H <chris-W4T7yFXR9VraRrIkyKz72Q@public.gmane.org> wrote:> > Howdy, > > I''ve done a bit of googling but I can''t seem to find something in rails > that converts metres to feet the way I need it. > > Eg, I have a wall height of 1.70 metres, which i convert to 5.5777 feet > using: > > def wall_height_to_ft > begin > (wall_height.to_f * 3.281).to_s > rescue > "0" > end > end > > So the result I get is really still in metres times by 3.281. The result > I need is 5 foot 7 inches or 5''7. Is there a easy way to do this in > rails without calculating it myself? > > Thanks in advance, > Chris. > > > > > > >--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I misread the bottom part of your post. I don''t think units will even do that conversion. the problem is that when you take measurements in feet/inches, inches are typically measured down to the 16th or 32nd of an inch. don''t know if you need that kind of precision or you just want the nearest inch. so say you do the following irb(main):032:0> wall_in_inches = 1.7.meters.to_inches => 66.92913379 so you could extract feet/inches by doing irb(main):057:0> feet = (wall_in_inches/12).floor => 5 irb(main):055:0> inches = wall_in_inches.remainder(12).round => 7 technically, you don''t even need units unless you need to do other unit conversions. On 4/2/07, Chris Hall <christopher.k.hall-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> http://rubyforge.org/projects/units/ > > > On 4/2/07, Chris H <chris-W4T7yFXR9VraRrIkyKz72Q@public.gmane.org> wrote: > > > > Howdy, > > > > I''ve done a bit of googling but I can''t seem to find something in rails > > that converts metres to feet the way I need it. > > > > Eg, I have a wall height of 1.70 metres, which i convert to 5.5777 feet > > using: > > > > def wall_height_to_ft > > begin > > (wall_height.to_f * 3.281).to_s > > rescue > > "0" > > end > > end > > > > So the result I get is really still in metres times by 3.281. The result > > I need is 5 foot 7 inches or 5''7. Is there a easy way to do this in > > rails without calculating it myself? > > > > Thanks in advance, > > Chris. > > > > > > > > > > > > > > >--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Apr 2, 2007, at 10:35 AM, Chris Hall wrote:> On 4/2/07, Chris Hall <christopher.k.hall-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> http://rubyforge.org/projects/units/ >> >> >> On 4/2/07, Chris H <chris-W4T7yFXR9VraRrIkyKz72Q@public.gmane.org> wrote: >>> >>> Howdy, >>> >>> I''ve done a bit of googling but I can''t seem to find something in >>> rails >>> that converts metres to feet the way I need it. >>> >>> Eg, I have a wall height of 1.70 metres, which i convert to >>> 5.5777 feet >>> using: >>> >>> def wall_height_to_ft >>> begin >>> (wall_height.to_f * 3.281).to_s >>> rescue >>> "0" >>> end >>> end >>> >>> So the result I get is really still in metres times by 3.281. The >>> result >>> I need is 5 foot 7 inches or 5''7. Is there a easy way to do this in >>> rails without calculating it myself? >>> >>> Thanks in advance, >>> Chris. > I misread the bottom part of your post. I don''t think units will even > do that conversion. > > the problem is that when you take measurements in feet/inches, inches > are typically measured down to the 16th or 32nd of an inch. don''t > know if you need that kind of precision or you just want the nearest > inch. > > so say you do the following > > irb(main):032:0> wall_in_inches = 1.7.meters.to_inches > => 66.92913379 > > so you could extract feet/inches by doing > > irb(main):057:0> feet = (wall_in_inches/12).floor > => 5 > irb(main):055:0> inches = wall_in_inches.remainder(12).round > => 7 > > technically, you don''t even need units unless you need to do other > unit conversions.If you''re going to do that, just use Numeric#divmod to get both values at once. irb(main):004:0> puts(%{%d''%2.0f"} % 66.92913379.divmod(12)) 5'' 7" -Rob Rob Biedenharn http://agileconsultingllc.com Rob-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
excellent thanks for your help guys. On Mon, 2007-04-02 at 11:29 -0400, Rob Biedenharn wrote:> On Apr 2, 2007, at 10:35 AM, Chris Hall wrote: > > On 4/2/07, Chris Hall <christopher.k.hall-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> http://rubyforge.org/projects/units/ > >> > >> > >> On 4/2/07, Chris H <chris-W4T7yFXR9VraRrIkyKz72Q@public.gmane.org> wrote: > >>> > >>> Howdy, > >>> > >>> I''ve done a bit of googling but I can''t seem to find something in > >>> rails > >>> that converts metres to feet the way I need it. > >>> > >>> Eg, I have a wall height of 1.70 metres, which i convert to > >>> 5.5777 feet > >>> using: > >>> > >>> def wall_height_to_ft > >>> begin > >>> (wall_height.to_f * 3.281).to_s > >>> rescue > >>> "0" > >>> end > >>> end > >>> > >>> So the result I get is really still in metres times by 3.281. The > >>> result > >>> I need is 5 foot 7 inches or 5''7. Is there a easy way to do this in > >>> rails without calculating it myself? > >>> > >>> Thanks in advance, > >>> Chris. > > I misread the bottom part of your post. I don''t think units will even > > do that conversion. > > > > the problem is that when you take measurements in feet/inches, inches > > are typically measured down to the 16th or 32nd of an inch. don''t > > know if you need that kind of precision or you just want the nearest > > inch. > > > > so say you do the following > > > > irb(main):032:0> wall_in_inches = 1.7.meters.to_inches > > => 66.92913379 > > > > so you could extract feet/inches by doing > > > > irb(main):057:0> feet = (wall_in_inches/12).floor > > => 5 > > irb(main):055:0> inches = wall_in_inches.remainder(12).round > > => 7 > > > > technically, you don''t even need units unless you need to do other > > unit conversions. > > If you''re going to do that, just use Numeric#divmod to get both > values at once. > > irb(main):004:0> puts(%{%d''%2.0f"} % 66.92913379.divmod(12)) > 5'' 7" > > -Rob > > Rob Biedenharn http://agileconsultingllc.com > Rob-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org > > > > > >--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---