Sunday, 15 July 2012

css - flash notification not working after following devise installation -



css - flash notification not working after following devise installation -

i followed 1 month rails tutorial , @ 1 point in tutorial told add together next lines application.html.erb enable flash messages

<% flash.each |name, msg| %> <%= content_tag(:div, msg, class: "alert alert-#{name}") %> <%end%>

what display messages after logging in or logging out css styles around them .

when followed along tutorial code works fine, when seek start own project, no longer has css styling around it. message still appear, it'll plain text on top of page.

the next application.html.erb

<!doctype html> <html> <head> <title>jmo</title> <%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %> <%= javascript_include_tag "application", "data-turbolinks-track" => true %> <%= csrf_meta_tags %> </head> <body> <div class = "container"> <% flash.each |name, msg| %> <%= content_tag(:div, msg, class: "alert alert-#{name}") %> <%end%> <%= render "layouts/header" %> <div class = "text-center"> <%= yield %> </div> <%= render "layouts/footer" %> </div> </body> </html>

and application.html.erb taken tutorial (the working version)

<!doctype html> <html> <head> <title>omrails</title> <%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %> <%= javascript_include_tag "application", "data-turbolinks-track" => true %> <%= csrf_meta_tags %> </head> <body> <div class = "container"> <!---require devise setup step 3--> <% flash.each |name, msg| %> <%= content_tag(:div, msg, class: "alert alert-#{name}") %> <%end%> <!---render header partial layouts/header--> <%= render "layouts/header" %> <%= yield %> <!---render footer partial layouts/header--> </div> <%= render "layouts/footer" %> </body> </html>

what doing wrong here?

edit: replaced non-working file working file , see message has no styling, thinking problem not within application.html.erb. else can problem be? thinking devise problem possibly?

to styles applied on html elements must defined somewhere either adding own styles or using external css library.

as far know, onemonthrails tutorial uses bootstrap-sass gem styling purposes.

in order same styling in new rails application, need add together gem gemfile

gem 'bootstrap-sass'

run bundle install install gem.

import bootstrap in app/assets/stylesheets/application.css.scss file adding next statement in it:

@import 'bootstrap';

and restart server.

css ruby-on-rails devise

No comments:

Post a Comment