railstutorial.org

Hartl Rails Tutorial Chapter 8.46 NoMethodError

独自空忆成欢 提交于 2019-12-11 20:21:40
问题 one my my tests receiving the following error in Chapter 8 of Hartl's Rails Tutorial. > 1) Error: > UsersLoginTest#test_login_with_valid_information_followed_by_logout: > NoMethodError: undefined method `forget' for #<Class:0x000000079be3b0> > app/helpers/sessions_helper.rb:30:in `forget' > app/helpers/sessions_helper.rb:37:in `log_out' > app/controllers/sessions_controller.rb:18:in `destroy' > test/integration/users_login_test.rb:40:in `block in <class:UsersLoginTest>' I have tried copying

Ruby (on Rails) syntax

天涯浪子 提交于 2019-12-11 16:21:27
问题 I am working back through the "Ruby on Rails 3 Tutorial" and trying to understand the syntax at a deeper level. Here is some example code from a helper action that I have defined: module ApplicationHelper def title base_title = "Mega Project" if @title.nil? base_title else "#{base_title} | #{@title}" end end end My question is about the line: "#{base_title} | #{@title}" What exactly is going on with the structure of this line? On a higher level, where is the go-to source to look up things

NoMethodError in UsersController#show / undefined method `key?' for nil:NilClass

喜欢而已 提交于 2019-12-11 05:31:09
问题 I've encountered an unexpected error while following Michael Hartl's Rails Tutorial . It had been smooth sailing. I first saw that I was getting a different "Action Controller: Exception caught" error than the Tutorial following the completion of Hartl's Listing 7.3. Specifically, when trying to reach /users/1, I get: NoMethodError in UsersController#show undefined method `key?' for nil:NilClass I continued on through Listing 7.5 - adding a view for for a User's show action and then adding

Hartl Ruby on Rails tutorial 4 ch 10, users edit test fails

一世执手 提交于 2019-12-11 05:05:55
问题 I am practicing Ruby on Rails by trying to create a custom website based off of Hartl's tutorial. Things have been going well so far but I am getting an error in the users edit test "Successful edit with friendly forwarding" in which the user is not redirected back to the edit page after logging in. This is the error message I get: FAIL["test_successful_edit_with_friendly_forwarding", UsersEditTest, 3.1409137547016144] test_successful_edit_with_friendly_forwarding#UsersEditTest (3.14s)

Rails Tutorial chapter 9.1.1 sign_in unrecognised

给你一囗甜甜゛ 提交于 2019-12-11 04:59:01
问题 I'm working through Michael Hartl's tutorial. I've just introduced these tests to user_pages_spec.rb describe "edit" do let(:user) { FactoryGirl.create(:user) } before do sign_in user visit edit_user_path(user) end describe "page" do it { should have_content("Update your profile") } it { should have_title("Edit user") } it { should have_link('change', href: 'http://gravatar.com/emails') } end describe "with invalid information" do before { click_button "Save changes" } it { should have

Can't push to git hub

不打扰是莪最后的温柔 提交于 2019-12-11 03:29:24
问题 I just completed Chapter One of the Ruby on Rails Tutorial by Hartl. Posted about one minor hitch previously. Now I started Chapter Two. I swear I did everything by the book, but now when I try: git push -u origin master I get the following messages after entering my passphrase: ERROR: repository not found fatal: could not read from remote repository Please make sure you have the correct access rights and that the repository exists. When I down loaded heroku tools I think it installed a

Rails Tutorial ch. 10 Test 10.20 failure

风格不统一 提交于 2019-12-11 03:18:31
问题 I have problem with test 10.20 in Rails Tutorial. After using command: bundle exec rake test:mailers I've received error: Run options: --seed 6131 # Running: F Finished in 0.559132s, 1.7885 runs/s, 5.3655 assertions/s. 1) Failure: UserMailerTest#test_account_activation [/home/adam/workspace/sample_app /test/mailers/user_mailer_test.rb:11]: Expected: ["noreply@example.com"] Actual: nil 1 runs, 3 assertions, 1 failures, 0 errors, 0 skips I've thoroughly checked my code and can't find the

How to use the image_tag with bootstrap class: “img-responsive” ? Chapter 11

心已入冬 提交于 2019-12-10 20:11:18
问题 The reason I’m asking the question is to get some help me with a really annoying syntax error. I'm using chapter 11 so I can build a blog section on my new site with images, everything is working apart from when i try to add class: "img-responsive" to this line. <%= image_tag image_article.picture.url if image_article.picture? %> I just can't figure out the correct syntax to add class: "img-responsive". The image is uploading fine but it breaks out of the col-md-6 container, and displays the

RailsTutorial: NoMethodError 'permanent' Rake::Test::CookieJar

微笑、不失礼 提交于 2019-12-10 18:36:11
问题 app/helpers/sessions_helper.rb module SessionsHelper def sign_in(user) cookies.permanent[:remember_token] = user.remember_token self.current_user = user end def sign_out self.current_user = nil cookies.delete(:remember_token) end def signed_in? !current_user.nil? end def current_user=(user) @current_user = user end def current_user @current_user ||= User.find_by_remember_token(cookies[:remember_token]) end end Tests defined in section 9.2.1 Requiring signed-in users are failing:- At first I

rspec test failure when switching from initializing attributes to Factory

穿精又带淫゛_ 提交于 2019-12-10 18:05:52
问题 This makes no sense to me, hope someone can help. I'm getting a single test failure when creating a user using a factory (seemingly similar tests pass). In my user_spec.rb test file, the user was originally created like this. Using this initialization approach, all tests pass. USER CREATION user_spec.rb (without factory) describe User do before do @user = User.new(name: "Example User", email: "user@example.com", password: "foobar", password_confirmation: "foobar", username: "username") end