FAQ Database Discussion Community


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

ruby-on-rails,railstutorial.org
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...

Route for mailer link

ruby-on-rails,ruby,ruby-on-rails-4,routes,railstutorial.org
Account activation The route and mailer link that I use for account account activation are as follows: # Route: resources :account_activations, only: [:edit] # Link in mailer: <%= edit_account_activation_url(@user.activation_token, email: @user.email) %> The link generates a link such as http://www.example.com/account_activations/q5lt38hQDc_959PVoo6b7A/edit?email=foo%40example.com. The controller method uses the email address to find the...

Rails Tutorial 7.4.3 SyntaxError in UsersController#show

ruby-on-rails,ruby,railstutorial.org
I'm doing the Michael Hartl tutorial and I made it to 7.4.3 The first signup. Then, when I try to signup, I receive an error: C:/Sites/sample_app/app/views/users/show.html.erb:1: syntax error, unexpected ',', expecting ')' ...putBuffer.new; provide (:title, @user.name) ... ^ C:/Sites/sample_app/app/views/users/show.html.erb:1: syntax error, unexpected ')', expecting keyword_end ...w; provide (:title, @user.name) ......

Phone Number Regex in Ruby — Anchor error with ^$

ruby-on-rails,ruby,regex,railstutorial.org
I'm trying to validate user phone numbers in Ruby with the following format: 123-456-7890 (123) 456-7890 123 456 7890 123.456.7890 +91 (123) 456-7890 I used the following regex: /^(\+\d{1,2}\s)?\(?\d{3}\)?[\s.-]?\d{3}[\s.-]?\d{4}$/ And got this error when trying to create a user in the rails console: ArgumentError: The provided regular expression is using...

MethodError: undefined method `sign_in' for RSpec

ruby-on-rails,ruby,rspec,railstutorial.org
In the Chapter 9 of the Ruby on Rails tutorial of Michael Hartl i am facing a problem with RSpec tests as they don't see my sign_in method defined in the file utilities.rb. I am stuck, I have checked everything and it seems correct. I saw similar posts where the...

ActionView::Template::Error (undefined method `phone' for #):

ruby-on-rails,ruby,ruby-on-rails-4,heroku,railstutorial.org
I finished creating user sign-up for my new rails app and everything worked fine in development on my local machine. But on heroku the deployed app will show the homepage and most other pages except the signup_path which renders "new.html.erb". Clicking this path gives me an error telling me to...

Rails Tutorial (3rd Ed) Integration tests not running because of invalid css selector (c9.io ?)

railstutorial.org
I'm going through the Rails Tutorial (using the cloud9 ide) (3rd Edition https://www.railstutorial.org/book/) and I'm running into something odd. I've just finished chapter 7, and I'm just now noticing that some of my assertions from chapter 5 are not running because "The assertion was not run because of an invalid...

Heroku App Crash err: uninitialized constant ApplicationController::SessionsHelper (NameError)

ruby-on-rails,ruby,heroku,railstutorial.org
I'm doing the Hartl tutorial and my rails app works fine in development, but crashes in heroku with this error code: application_controller.rb:5:in `<class:ApplicationController>': uninitialized constant ApplicationController::SessionsHelper (NameError) This happened after I added a remember_digest to the schema. Not sure if it's migrations or an issue between SessionHelper and ApplicationController ApplicationController...

RailsTutorial Ch 9 Test fail on pagination and delete link

ruby,ruby-on-rails-4,railstutorial.org,will-paginate,minitest
Going through rails tutorial and stuck on chapter 9 for this last error. FAIL["test_index_as_admin_including_pagination_and_delete_links", UsersIndexTest, 1.799453] test_index_as_admin_including_pagination_and_delete_links#UsersIndexTest (1.80s) <delete> expected but was <User 19>.. Expected 0 to be >= 1. test/integration/users_index_test.rb:18:in `block (2 levels) in <class:UsersIndexTest>' test/integration/users_index_test.rb:15:in `block in <class:UsersIndexTest>' Here is my test block from users_index_test.rb...

My Rails Tutorial (Chapter 7) Heroku deployment with puma keeps crashing

ruby-on-rails,ruby,heroku,railstutorial.org,puma
This is my first question here so I hope I'm within the rules. I've just completed Chapter 7 of the Michale Hartl Rails Tutorial. My sample_app works locally and has worked on Heroku until this point. At the end of the chapter is a section called "7.5 Professional-grade deployment." This...

NoMethodError in SessionsController#destroy undefined method `forget' for nil:NilClass

ruby-on-rails,ruby,railstutorial.org
Working through Rails Tutorial by M. Hartl Ch 8 Log in, Log out When attempting to log out of my application, I receive the error message given in the title of my question. I'm very new to this, but I think this means that the forget instance method defined in...

Hartl Tutorial + Omniauth: Log In not Logging In

ruby-on-rails,ruby,facebook,railstutorial.org,railscasts
I tried integrating omniauth with Hartl tutorial user signup authentication. I thought about switching the hartl tutorial authentication to Devise and then Devise to omniauth (since their is a Railscast episode for that), but I'm worried the switch from Hartl to Devise will be the most difficult integration out of...

NoMethodError in Rails::MailersController#preview undefined method `activation_token=' for nil:NilClass

ruby-on-rails,ruby,railstutorial.org
Cannot seem to find a working answer for this. I'm on Chapter 10, section 10.1.2 of the Rails Tutorial and can't seem to get the mailer preview working. All the answers I've found dealing with the error are related to different sections of the tutorial, and I'm assuming the error...

NoMethodError: undefined method reset_sent_at hartle tutorial

ruby-on-rails,railstutorial.org,nomethoderror
I'm doing chapter 10 of enter link description here. I got the same error mentioned in enter link description here PasswordResetsTest#test_password_resets: NoMethodError: undefined method `reset_sent_at=' for #<User:0xccd47c0> app/models/user.rb:66:in `create_reset_digest' app/controllers/password_resets_controller.rb:12:in `create' test/integration/password_resets_test.rb:17:in `block in <class:PasswordResetsTest>' I try to do everything mentioned in the answer. first thing I did was: rails...

Heroku run rake db:seed gives expecting keyword_end

ruby-on-rails,heroku,railstutorial.org
I'm doing chapter 11 of hartle's tutorial. At the end of this chapter I ran heroku run rake db:seed And I got this error: rake aborted! SyntaxError: /app/db/seeds.rb:23: syntax error, unexpected end-of-input, expecting keyword_end This is my seeds.rb file: User.create!(name: "Example User", email: "[email protected]", password: "foobar", password_confirmation: "foobar", admin: true,...

Rails Tutorial: Testing Error (Cannot Load Such File)

ruby-on-rails,ruby,railstutorial.org
Complete beginner here. I've been working through the Hartl Rails tutorial--currently the "Advanced Testing Setup" for the optional exercises in Chapter 3. Though testing was running smoothly beforehand, I'm getting the following error upon running either "rake test" or "guard": LoadError: cannot load such file -- /home/ubuntu/workspace/sample_app/test/config/environment /usr/local/rvm/gems/[email protected]/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:274:in `require'...

Rails Tutorial Chapter 6 create user error “SELECT 1 AS one FROM ”users“ WHERE LOWER(”users“.”email“) = LOWER('[email protected]') LIMIT 1”

ruby-on-rails,ruby,railstutorial.org
I am following the rails tutorial and when I try to make a user through the rails console, this error SELECT 1 AS one FROM "users" WHERE LOWER("users"."email") = LOWER('[email protected]') LIMIT 1 This is my user model class User < ActiveRecord::Base before_save { self.email = email.downcase } validates :name, presence:...

RoR Tutorial Chapter 3 - Guard detects changes but doesn't fully execute tests

ruby-on-rails,railstutorial.org,minitest,guard
I'm currently following the book and the video and in the video, Hartl runs a guardfile so that it automatically runs tests after any changes have been made. So in the videos when he presses return whilst in guard mode, it says: 17:35:31 - INFO - Running: test/controllers/static_pages_controller_test.rb followed by...

Heroku Rails Migration error

ruby-on-rails,ruby,activerecord,heroku,railstutorial.org
I finished creating user sign-up for my new rails app and everything worked fine in development on my local machine. But on heroku the deployed app will not load the signup_path which renders "new.html.erb". Clicking this path gives me an error telling me to check my logs. I've checked the...

Can't open Hartl's sample_app on local server

ruby-on-rails,railstutorial.org
I'm going trough Hartl's tutorial and everything was ok until 11th chapter. I did everything in chapter 11 as was required(few times, maybe that is problem?) and suddenly I can't open app on local server. Problems begun when i was supposed to seed database, so I reset it and (unsuccessfully)...

How to grant permissions to AWS user for Hartl's rails tutorial

ruby-on-rails,amazon-web-services,railstutorial.org,iam
I don't know how (or where also) to grant read and write permission to the user from AWS so users can post pictures on sample_app in production enviroment. This is final task in 11th chapter, it isn't covered by tutorial and I can't find solution anywhere. So, if someone can...

Problems with defining @shops variable NoMethodError

ruby-on-rails,ruby,railstutorial.org
I've created two user models called "user" and "shop". When I try to use the @shop variable as shop (like in shop.name) it will not work, but user.name will work. So I missed defining shop at some point, and cannot figure out where to fix it. Here's the error I...

Navbar login form in a Rails web app (with Bootstrap)

ruby-on-rails,forms,twitter-bootstrap,session,railstutorial.org
I'm making a Rails web app with the limited knowledge I have - mostly from the Hartl Rails Tutorial. I'm also using Bootstrap. I decided it would be good to have a dropdown login form in the navbar, in addition to the form at '/login'. The form looks nice enough,...

Parameter passing and assert_difference

ruby-on-rails,ruby,railstutorial.org
I am new to both Ruby and Rails. I don't understand why the following code (which uses Rails' [ActiveSupport::Testing.assert_difference]1 method) doesn't require a comma after the parameter 1. The code comes from Chapter 7 of the Rails Tutorial. assert_difference 'User.count', 1 do post_via_redirect users_path, ... end The signature for assert_difference...

Unable to seed database in rails tutorial

ruby-on-rails,railstutorial.org
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'...

Rails can't find installed gem

ruby-on-rails,ruby,ruby-on-rails-3,railstutorial.org
I'm following a tutorial for Rails that specifically asks for version 4.2.0 so I installed Rails with sudo gem install rails -v 4.2.0 and it worked fine. When I try to create a new application with rails _4.2.0 new test_app I get an error message that says /Library/Ruby/Site/2.0.0/rubygems/dependency.rb.315: in 'to_specs':...