Reputation: 1397
total noob to rails and am using the Hartl tutorial.
Got to chapter 4 (CSS, 4.1.2), everything seemed dandy, and ran into an issue getting
<!DOCTYPE html>
<html>
<head>
<title><%= title %></title>
<%= csrf_meta_tag %>
<%= stylesheet_link_tag 'blueprint/screen', :media => 'screen' %>
<%= stylesheet_link_tag 'blueprint/print', :media => 'print' %>
</head>
<body>
<%= yield %>
</body>
</html>
to make the text on the page look 'prettier'. As Hartl describes it, 'By the way, with the new stylesheets the site doesn’t look much different than before, but it’s a start'
I do agree it looks cooler and this step is obviously more than necessary to continue.
So, nothing was changing on the localhost:3000/pages/home as it looked in chapter 3.
This is what it SHOULD look like
http://ruby.railstutorial.org/images/figures/home_with_stylesheet.png
(see attached pic^)
So I finally moved the stylesheets folder from public into app/assets/stylesheets, and added
this
<%= stylesheet_link_tag 'application.css' %>
to the application.html.erb file in app/views/layouts folder Which I found from this portion of stackoverflow :) very helpful
So I fired up localhost:3000/pages/home and everything looked as it should (in relation to the png pic posted above) but all the text was centered, and it should be on the left side.
And, in addition, I was getting this message, repeated, in the terminal:
Started GET "/assets/stylesheets/src/typography.css?body=1" for 127.0.0.1 at 2012-01-04 17:34:13 -0800
Served asset /stylesheets/src/typography.css - 304 Not Modified (3ms)
[2012-01-04 17:34:13] WARN Could not determine content-length of response body. Set content- length of the response or set Response#chunked = true
So a buddy said it had to do with the rails version. We did share screen skype and he said in the home directory it should be 3.1 and in the sample_app directory it should be version 3.0.11 (he's a bit of a noob too but everything is going smoothly for him)
So alas I am back to getting the damn rails server to work. I'm on Snow Leopard and changed the sqlite3 thing, did bundle update then bundle install and worked fine. Now 'rails s' will not work ;/
the error message in the terminal is this:
/Users/davidpardy/rails_projects/sample_app/config/application.rb:8:in `require': no such file to load -- sprockets/railtie (LoadError)
from /Users/davidpardy/rails_projects/sample_app/config/application.rb:8:in '<top (required)>'
from /Users/davidpardy/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.0.11/lib/rails /commands.rb:28:in `require'
from /Users/davidpardy/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.0.11/lib/rails/commands.rb:28:in `block in <top (required)>'
from /Users/davidpardy/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.0.11/lib/rails/commands.rb:27:in `tap'
from /Users/davidpardy/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.0.11/lib/rails/commands.rb:27:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
So now I'm stuck and really don't know what to do. Don't want to start from scratch.
Like I said I'm new to this so any input would be appreciated. This seems like a rather easy fix, just lost.
Upvotes: 0
Views: 325
Reputation: 36
im in the same boat as you, i am running rails 3.1.3 and am not in the mood atm to start over for a lower rails (or to figure out how to seamlessly change rails version).
i decided to remove the blueprint folder and its two including lines in application.html.erb, and make a new inclusion of a custom css file i put directly in app/assets/stylesheets. the css was just to make the background red, and thats what it did. not sure why our pages were being centered like that using the blueprint, but it looks okay now. as mentioned earlier, the safest bet is to just use the same versions as the tutorials, or 3.0.11 for rails as mr. hartl has indicated in a comment.
Upvotes: 1
Reputation: 8526
Per the answer to Trouble loading Rails Server (3.0.11, ruby 1.9.2), no such file to load -- sprockets/railtie (LoadError), you should remote Rails 3.1-specific lines from auto-generated files, mostly in config/
.
One way to figure out what lines to remove is to compare your app to a fresh Rails 3.0 app using diff -r
Step 1: Create a clean Rails 3.0 app
$ rails --version
Rails 3.0.10
$ rails new fresh_app
create
create README
create Rakefile
Step 2: Use diff -r
to compare the directories
$ diff -r hartl_tutorial/config fresh_app/config
diff -r hartl_tutorial/config/application.rb fresh_app/config/application.rb
5,10c5,7
< if defined?(Bundler)
< # If you precompile assets before deploying to production, use this line
< Bundler.require(*Rails.groups(:assets => %w(development test)))
< # If you want your assets lazily compiled in production, use this line
< # Bundler.require(:default, :assets, Rails.env)
< end
---
> # If you have a Gemfile, require the gems listed there, including any gems
> # you've limited to :test, :development, or :production.
> Bundler.require(:default, Rails.env) if defined?(Bundler)
In case you don't know how to read a diff, the basic idea is that lines starting with < are from one file while lines starting with > are from the other file.
Upvotes: 0