ruby on rails - I got the MissingTemplate error but not knowing the reason -
i access page https://lazyair.co/specials/2015-09-25-02
correctly,
and have template specials.html.haml
but still show me actionview::missingtemplate
how happen ? direction ? thanks
controller
def specials @specials = special.all end
exception
an actionview::missingtemplate occurred in welcome#specials: missing template welcome/specials, application/specials {:locale=>[:"zh-tw", :zh], :formats=>["image/webp", "image/*"], :variants=>[], :handlers=>[:erb, :builder, :raw, :ruby, :coffee, :haml, :jbuilder]}. searched in: ------------------------------- request: ------------------------------- * url : https://lazyair.co/specials/2015-09-25-02 * http method: * parameters : {"controller"=>"welcome", "action"=>"specials", "token"=>"2015-09-25-02"} * process: 7573
because question lacks of finer details, here's i'd do:
#app/controllers/welcome_controller.rb class welcomecontroller < applicationcontroller def index @specials = special.all end def show @specials = special.find params[:id] end end #app/views/welcome/show.html.haml ... #config/routes.rb resources :welcome, path: "specials", only: [:show] #-> url.com/specials/:id
i understand changes method name (i'd rather use conventional routing make special method names). should give structure required negate error.
further, if you're using in sort of "deal" app, you'll want following:
#app/controllers/specials_controller.rb class specialscontroller < applicationcontroller def index @specials = special.all end end #app/views/specials/index.html.haml <% @specials.each |special| %> <%= special.x %> <% end %>
Comments
Post a Comment