Errno::EACCES in Welcome#index - mysql

I'm getting this error after creating a test app on Rails 4.1.5 , currently running on a test enviroment configured with apache and mysql, using passenger, on Fedora 21 so far I´ve tried everything regarding ownership and permissions, but it is still not working.
Permission denied # dir_s_mkdir - /var/www/html/blog/tmp
(in /var/www/html/blog/app/assets/stylesheets/welcome.css.scss)
Extracted source (around line #5):
<html>
<head>
<title>Blog</title>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-
track' => true %>
<%= javascript_include_tag 'application', 'data-turbolinks-track' =>
true %>
<%= csrf_meta_tags %>
</head>
Rails.root: /var/www/html/blog

Related

multiple views with multiple rails layouts for multiple head scripts

I want each of my view files to have their own layout because each one needs different stuff in their <head> tags with different scripts being run but they should still inherit the same stuff from layouts/application.html.erb. Is this possible?
layouts/application.html.erb -> layouts/a.html.erb -> views/a.index.html.erb
layouts/application.html.erb -> layouts/b.html.erb -> views/b.index.html.erb
content_for :header_tags is for adding extra lines to the <head> of your application.html.erb or base.html.erb. Here's a live example from whatever.html.erb:
<% content_for :header_tags do %>
<%= javascript_include_tag :redmine_helpdesk, :plugin => 'redmine_contacts_helpdesk' %>
<%= stylesheet_link_tag :helpdesk, :plugin => 'redmine_contacts_helpdesk' %>
<% end %>
Then the base.html.erb calls <%= yield :header_tags -%> to express whatever was stored with the :header_tags key.

Exclude a partial from certain views

in my current Rails app, I have a partial in my layouts folder for a navigation sidebar. I would like this sidebar to render for every page of my app except the new and thankyou actions of my score controller, because those two views are going to be a part of an iframe. To do this, I'm making another layout called iframe.html.erb where I'd like to put the logic to exclude the navigation sidebar.
Here is my application.html.erb layout file
<!DOCTYPE html>
<html>
<head>
<title>NPS</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 id="wrapper">
<%= render 'shared/navigation' %>
<%= yield %>
</div>
</body>
</html>
And here is my iframe.html.erb file
<!DOCTYPE html>
<html>
<head>
<title>NPS</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 id="wrapper">
<%= if (current_page?(controller: 'scores', action: 'new') || current_page?(controller: 'scores', action: 'thankyou' )) do %>
<%= yield %>
<% end %>
</div>
</body>
</html>
I initially just had an unless statement in my application layout but that wouldn't work on the sign-in page because devise would be looking for those scores views in the devise folder. I'm also not very good with html.erb so I'm sorry if it's just a syntax thing.
Edit:
Here is the error I get with devise
ActionController::UrlGenerationError at /users/sign_in
No route matches {:action=>"new", :controller=>"devise/scores"}
Thanks
in your application.html.erb...
<%= render 'shared/navigation' unless #disable_nav %>
Then in your score controller where you have you have your two views...
def new
#disable_nav = true
# ...
end
def thankyou
#disable_nav = true
# ...
end
You don't need two layouts for that and your syntax is incorrect. Remove iframe.html.erb.
There are several ways to do it. Try this one in application.html.erb:
<div id="wrapper">
<% if !current_page?(controller: 'scores', action: 'new') && !current_page?(controller: 'scores', action: 'thankyou') %>
<%= render 'shared/navigation' %>
<% end %>
<%= yield %>
</div>
It should just work. However, it can be improved. Move this logic into your application_helper.rb:
def should_show_navigation?
!current_page?(controller: 'scores', action: 'new') &&
!current_page?(controller: 'scores', action: 'thankyou')
end
And then, in your layout file (application.html.erb):
<div id="wrapper">
<% if should_show_navigation? %>
<%= render 'shared/navigation' %>
<% end %>
<%= yield %>
</div>
It gets more readable.

Ruby On Rails Syntax error in Welcome#Index

I was implementing bootstrap into my ruby on rails app and now I've got the following error:
Sass::SyntaxError in Welcome#index
Showing /home/ubuntu/workspace/app/views/layouts/application.html.erb where line #6 raised:
File to import not found or unreadable: bootstrap-sockets.
Load paths:
/home/ubuntu/workspace/app/assets/images
/home/ubuntu/workspace/app/assets/javascripts
/home/ubuntu/workspace/app/assets/stylesheets
/home/ubuntu/workspace/vendor/assets/javascripts
/home/ubuntu/workspace/vendor/assets/stylesheets
/usr/local/rvm/gems/ruby-2.1.5#rails4/gems/turbolinks-2.5.3/lib/assets/javascripts
/usr/local/rvm/gems/ruby-2.1.5#rails4/gems/jquery-rails-3.1.2/vendor/assets/javascripts
/usr/local/rvm/gems/ruby-2.1.5#rails4/gems/coffee-rails-4.0.1/lib/assets/javascripts
/usr/local/rvm/gems/ruby-2.1.5#rails4/gems/bootstrap-sass-3.3.4.1/assets/stylesheets
/usr/local/rvm/gems/ruby-2.1.5#rails4/gems/bootstrap-sass-3.3.4.1/assets/javascripts
/usr/local/rvm/gems/ruby-2.1.5#rails4/gems/bootstrap-sass-3.3.4.1/assets/fonts
/usr/local/rvm/gems/ruby-2.1.5#rails4/gems/bootstrap-sass-3.3.4.1/assets/images
/usr/local/rvm/gems/ruby-2.1.5#rails4/gems/bootstrap-sass-3.3.4.1/assets/stylesheets
(in /home/ubuntu/workspace/app/assets/stylesheets/application.css.scss:17)
Extracted source (around line #6):
3
4
5
6
7
8
9
<head>
<title>Bloccit</title>
<meta name="viewport" content="width=device-width, initial-scale=1"
<%= stylesheet_link_tag "application", media: "all" %>
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
<%= csrf_meta_tags %>
</head>
Rails.root: /home/ubuntu/workspace
Application Trace | Framework Trace | Full Trace
app/assets/stylesheets/application.css.scss:17
app/views/layouts/application.html.erb:6:in `_app_views_layouts_application_html_erb___973947755503535086_42092360'
Request
Parameters:
None
Toggle session dump
Toggle env dump
Response
Headers:
None
What could be causing it?
It shows that error is in your
app/assets/stylesheets/application.css.scss:17
Please check that properly and let me know.

Why does my title tag not appear on search results using Ruby on Rails?

I'm trying to add a title tag to my website using ROR.
After adding the desired changes to ... in aplication.html.erb, then commiting and deploying it, I still do not see the complete title tag present with the changes I just made when I view the website on search results.
Why is this the case and is there anything I am forgetting to include?
<!DOCTYPE html>
<html>
<head>
<title>Website Name - Desired title tag added here but doesn't show in search results</title>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
<%= csrf_meta_tags %>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<%= render 'shared/user_info' %>
</head>
<body>
<div id="body-interior">
<%= render 'shared/header' %>
<div class="container">
<% flash.each do |name, msg| %>
<%= content_tag(:div, msg, class: "alert alert-info") %>
<% end %>
<%= yield %>
</div>
<%= render 'shared/footer' %>
</div>
<%= render 'shared/final_scripts' %>
</body>
</html>
Thanks!
When you say search results, I assume you mean search engines like Google? If so, you need to know that changes like these won't be recognized instantly by Google. The changes should be visible as soon as Google (or any other robot) crawls the page in question again.
As far as I know you can force this process with Google's Webmaster Tools.

Show a different style sheet depending on page in rails 4

I am trying to render different CSS depending on the page. I did some research
How does one load a CSS framework in Rails 3.1?
https://github.com/rails/rails/issues/1981
and of course the rails guide on the asset pipeline.
What I want is for the index(home page) to render one css file(welcome.css.scss) and the others to render users.css.scss.
Right now when you navigate to the page it renders the welcome.css.scss and then when I hit sign in it is still rendering welcome.css.scss. But after refreshing the page it will then render the user.css.scss
I updated my assets.rb file:
Rails.application.config.assets.precompile += %w( welcome.css )
Rails.application.config.assets.precompile += %w( users.css )
Then I created a welcome.html.erb
<!DOCTYPE html>
<html>
<head>
<title>Blocmarks</title>
<%= stylesheet_link_tag "welcome" %>
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
<%= csrf_meta_tags %>
</head>
<body>
<%= yield %>
</body>
</html>
and a users.html.erb file
<!DOCTYPE html>
<html>
<head>
<title>Blocmarks</title>
<%= stylesheet_link_tag 'users' %>
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
<%= csrf_meta_tags %>
</head>
<body>
<%= yield %>
</body>
</html>
I removed the require from the application.css.scss. The only thing in the file at this time is #import 'bootstrap';
and of course I have a welcome and a user.css.scss.
Results from the console:
-Navigate to the home page
Started GET "/" for 127.0.0.1 at 2014-10-25 13:04:11 -0500
ActiveRecord::SchemaMigration Load (0.3ms) SELECT "schema_migrations".* FROM "schema_migrations"
Processing by WelcomeController#index as HTML
Rendered welcome/index.html.erb within layouts/welcome (13.0ms)
Completed 200 OK in 471ms (Views: 446.7ms | ActiveRecord: 0.0ms)
Navigate to the users/sign-in
Started GET "/users/sign_up" for 127.0.0.1 at 2014-10-25 13:04:57 -0500
Processing by Devise::RegistrationsController#new as HTML
Rendered devise/shared/_links.erb (2.7ms)
Rendered devise/registrations/new.html.erb within layouts/devise (615.4ms)
Completed 200 OK in 896ms (Views: 890.9ms | ActiveRecord: 0.9ms)
Refresh the users/sign page:
Started GET "/users/sign_up" for 127.0.0.1 at 2014-10-25 13:06:02 -0500
Processing by Devise::RegistrationsController#new as HTML
Rendered devise/shared/_links.erb (0.8ms)
Rendered devise/registrations/new.html.erb within layouts/devise (7.4ms)
Completed 200 OK in 308ms (Views: 306.3ms | ActiveRecord: 0.0ms)
I also created a gist with the full console results to show what it is GETting first:
https://gist.github.com/tjperry07/b3093c0b7f16b5e000b0
This is happening because of rails turbolinks. It makes following links in your web application faster. Instead of letting the browser recompile the JavaScript and CSS between each page change, it keeps the current page instance alive and replaces only the body and the title in the head.
If you look at guides or turbolinks docs. It's clearly stated that
If using the turbolinks gem, which is included by default in Rails 4, then include the 'data-turbolinks-track' option which causes turbolinks to check if an asset has been updated and if so loads it into the page
FIX:
Replace your stylesheet tags with these:
<%= stylesheet_link_tag "welcome", media: "all", "data-turbolinks-track" => true %>
<%= stylesheet_link_tag "users", media: "all", "data-turbolinks-track" => true %>