I need message to have a different layout in project, is it possible in rails to do something like this?
Class Messages::New < @project? ProjectLayout : NormalLayout
end  #i treid this, don't work, since @project has not been initiated.
thanks
A layout defines the surroundings of an HTML page. It's the place to define a common look and feel of your final output. Layout files reside in app/views/layouts. The process involves defining a layout template and then letting the controller know that it exists and to use it.
this may help you
class MessagesController < ApplicationController
  layout :get_layout
  def get_layout
    @project? ? 'ProjectLayout' : 'NormalLayout'
  end
end
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With