railstutorial.org

Can't modify Application Controller for 'hello world' app

亡梦爱人 提交于 2019-12-24 22:29:28
问题 I've stumbled at Chp 1, Listing 1.8 of Hartl's tutorial. The goal is to place a hello action into the Application controller. This is supposed to happen: class ApplicationController < ActionController::Base # Prevent CSRF attacks by raising an exception. # For APIs, you may want to use :null_session instead. protect_from_forgery with: :exception` def hello render text: "hello, world!" end end Instead, when I put in the first line class ApplicationController < ActionController::Base I get this

Unable to seed database in rails tutorial

故事扮演 提交于 2019-12-24 13:52:44
问题 11.2.2 First I migrated db(bundle exec rake db:migrate:reset), then I try to seed it(bundle exec rake db:seed) and I get this message: rake aborted! SyntaxError: /home/aki/sample_app/db/seeds.rb:25: syntax error, unexpected end-of-input, expecting keyword_end /home/aki/.rvm/gems/ruby-2.1.3/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:268:in `load' /home/aki/.rvm/gems/ruby-2.1.3/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:268:in `block in load' /home/aki/.rvm

Password validation fails in two opposed scenarios

不羁岁月 提交于 2019-12-24 12:15:00
问题 I am working through the Ruby on Rails Tutorial by Michael Hartl and have generated an interesting dilemma. I will have done something wrong, so I need your help finding the issue. The issue surrounds the validation of a password property within a User model. The initial validation of this property was: validates :password, presence: true, confirmation: true, length: { minimum: 6 } This requires a minimum length of the password and is designed to satisfy the situation where a new user creates

Michael Hartl Rails Tutorial (3.2) - Chapter 5 Rspec issue

爱⌒轻易说出口 提交于 2019-12-24 11:32:53
问题 I've completed Chapter 5 and all the exercises. As part of the final exercise, MH has you write tests for the ApplicationHelper method. Once that is done, individual tests pass with: shift-command-T in ST2 (using the sublime-text-2-ruby-tests package) rspec spec/requests/user_pages_spec.rb in the terminal rspec spec/requests/static_pages_spec.rb in the terminal However, if I run all tests with rspec spec/ in the terminal I get this error: /Users/anonymouscoward/rails/railstut/sample_app/spec

Deploying Rails app to Heroku after previously taking Gemfile.lock out of repository

百般思念 提交于 2019-12-24 11:32:33
问题 I'm working through the Rails 3.2 edition of Ruby on Rails Tutorial, and am right near the end of Chapter 5. Although it accepted my code a few days ago, Heroku no longer wants to take it when I push. It complains that it needs a Gemfile.lock, which I can understand -- but I am supplying one already. A few days ago I did remove Gemfile.lock from the repository, since I started this project on Windows and ran into Bundler hell due to that. At that time, I added Gemfile.lock's name to

RoR Tutorial Chapter 4.1.1, confused why title helper doesn't fail

徘徊边缘 提交于 2019-12-24 11:32:32
问题 I'm going through Michael Hartl's Ruby on Rails 3.2 Tutorial and I'm confused about why the title helper found in Section 4.1.1 doesn't fail. He talks about needing a title helper in the event that you leave out this bit of code from the view: <% provide(:title, 'Home') %> But in the application layout file there is this line: <title><%= full_title(yield(:title)) %></title> Doesn't that pass a nil value to the full_title helper since the provide isn't setting a value to the :title symbol?

ExecJS::ProgramError in Rails tutorial demo app

醉酒当歌 提交于 2019-12-24 11:25:37
问题 I'm following demo app tutorial on http://ruby.railstutorial.org/chapters/a-demo-app#sec:planning_the_application. After generate scaffold for users. when i try to access localhost:3000/users. I got the following error on ExecJS Started GET "/users" for 127.0.0.1 at 2012-08-01 13:35:37 -0500 Connecting to database specified by database.yml Processing by UsersController#index as HTML User Load (0.1ms) SELECT "users".* FROM "users" Rendered users/index.html.erb within layouts/application (3.1ms

rails generate - “Could not find generator”

末鹿安然 提交于 2019-12-23 09:37:04
问题 I am following the Ruby on Rails tutorial by Michael Hartl. In section 6.3.1, I am trying to generate a migration file to add a Password field to my user model. Here is the code that I run: rails generate add_passsword_digest_to_users password_digest:string but this throws the error: Could not find generator add_passsword_digest_to_users. i have used the rails generate command before and it worked perfectly. I'm not sure why I am getting this problem now. version: Rails 3.2.8, ruby 1.9.3p194

Capybara::ElementNotFound: Error

狂风中的少年 提交于 2019-12-23 03:12:56
问题 i am following railstutorial.org tutorial i am getting the following error 1) User pages signup with valid information should create a user Failure/Error: fill_in "password" , with: "foobar" Capybara::ElementNotFound: cannot fill in, no text field, text area or password field with id, name, or label 'password' found # (eval):2:in `fill_in' # ./spec/requests/user_pages_spec.rb:32:in `block (4 levels) in <top (required)>' 2) Authentication signin with invalid information Failure/Error: before {

Capybara::ElementNotFound: Error

这一生的挚爱 提交于 2019-12-23 03:12:06
问题 i am following railstutorial.org tutorial i am getting the following error 1) User pages signup with valid information should create a user Failure/Error: fill_in "password" , with: "foobar" Capybara::ElementNotFound: cannot fill in, no text field, text area or password field with id, name, or label 'password' found # (eval):2:in `fill_in' # ./spec/requests/user_pages_spec.rb:32:in `block (4 levels) in <top (required)>' 2) Authentication signin with invalid information Failure/Error: before {