Git Product home page Git Product logo

sample_app_rails_4's People

Contributors

amanhigh avatar arunthampi avatar chaadow avatar mhartl avatar pboling avatar railstutorial avatar unchris avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sample_app_rails_4's Issues

Chapter 2 - Validation not working

When I used the code in Listing 2.13, the validation does not work in the browser.

class Micropost < ApplicationRecord
  validates :content, length: { maximum: 140 }
end

I had to add "presence: true" to get it to work.

class Micropost < ApplicationRecord
  validates :content, presence: true, length: { maximum: 140 }
end

I'm not sure if this is a recent update or if it's just not working properly for me...

Update Sass Gem to 3.1

Other gems have moved to being depending on Sass 3.1
However moving the sample app over breaks a lot of styling, a lot of use aren't css wizards and could use some guidance (examples) on the conversion.

Chapter 6.3.3 - Valid password test not passing.

Howdy,
I've been racking my brain trying to figure this out. I'm not sure why, but for some reason my password digest hash isn't matching up. When I run the test I get this error:

expected: password_digest: "$2a$04$cDKhuWzsZuW8Gm4t5fJjpu6rmbwh10ZAt2Yae.BO0iuD...">
got: password_digest:      "$2a$04$jwfHjoLI0RpDIAEr9SMKGOZqeH.J5ILOkzalKCYQdDW4...">

I should note that the application code works just fine. I can call user.authenticate('foobar') in the console and it'll work as expected.

I'm not sure if this has anything to do with it, but I'm using postgres as my local database and I can't get to test to even run properly unless I explicitly run rake db:test:prepare in the test environment. When I drop and rebuild the database I get the user spec to pass, but run it a second time and it doesn't match up anymore. I'm not sure what to do and don't think that using postgres is responsible for this error, but it's the only difference I can account for.

I have my full user_spec here: https://gist.github.com/DavidVII/f190d1f1e114234bb7d7#file-user_spec-rb-L107

The part causing the problem is on line 107.

Please help!

Some tests don't fail when they should w/ Guard

Issue: Tests should fail but don't until Guard is stopped and restarted and tests should pass but don't until Guard is restarted.

Steps:

  • Type guard to launch it and run the 147 tests
  • Edit file app/helpers/application_helper.rb and break base_title on line 5, assigning base_title = "whatever"
  • Guard only runs 3 tests (instead of the original 147) when the file is saved and they are still passing
  • Stop Guard with Ctrl+D and restart it, now tests fail as they should.
  • Fix app/helpers/application_helper.rb by restoring base_title on line 5 to its original value
  • Watch Guard running only 3 tests and still fail
  • Stop Guard and restart it, now the tests are passing again.

Thanks for the brilliant tutorial, I hope raising this issue helps make it even better.

Chapter 12 - syntax no longer valid

Chapter 12 - 12.3.3 - Figure 12.18

In "test/integration/password_resets_test.rb", the params syntax in here throws errors unless removed, per stackoverflow - Link:

... # Valid email
    post password_resets_path,
         params: { ...

Working example of that issue resolved (I have one more lingering issue in this github example)... Link

PostgreSQL installation required

There should be some sort of documentation around this, as lack of PostreSQL installation causes bundle install to fail on pg.

"bundler binstubs may be unsafe" warning on OSX

I don't know if this is a real issue, or if you just need to address the warning message, but after setting up Bundler Binstubs I received the following warning in OSX Terminal when I switched into my project directory:

The bundler binstubs directory is in the current directory, which may be unsafe.
Consider using rubygems-bundler instead => https://github.com/mpapis/rubygems-bundler
Remove the BUNDLE_BIN line from .bundle/config to disable this prompt.
Are you sure you want to add the bundler binstubs directory to the path?
(anything other than 'Yes' will cancel) >"

I don't know the in's and out's of this issue, so I would be interested in your opinion on what the best approach is. Either way, I suggest that you address the warning in the text or switch to the recommended method. Thanks.

Issue adding validation for secure password

Working through adding user validations and all good until I add the secure password validation. I've done the migrations, added bcrypt and done the bundle install. When I add has_a_secure_password to the user model I get a fail, but when I add the corresponding password and password_confirmation attributes to the setup in test/models/user_test.rb, it keeps failing. I tried to check the reference implementation here, but it seems to use a different test suite (rspec?) Nothing seems to correspond to the online edition I'm using (3rd edition)

Heroku problem

When i try deploying no herouku sample_app , i get the error message:
` Application error

An error occurred in the application and your page could not be served. If you are the application owner, check your logs for details. `
I use Ruby 2.4.2 and Rails 5.1.4.

Ask for providing current password when editing user

I found that when editing user, I could update all the attributes(include password) without providing current password, consider about that the cookie is permanent( 20 years ), I think maybe this is not safe since everyone can change the user's password or email without authentication if the user did not sign out. Or am I missing somthing?

Thank you for your consideration :)

Typo in chapter 6.3.3

The tutorial reads

The second step is then to use an authenticate method to verify that the user has the given password. In Chapter 8, we’ll retrieve the current (signed-in) user using code something like this:

It seems the word "code" is redundant.

A bug of chapter 9 practice-1 Code 9.48

The Code 9.48 you write like these:

    require 'spec_helper'

    describe "User pages" do
      .
      .
      .
      describe "edit" do
        .
        .
        .
        describe "forbidden attributes" do
          let(:params) do
            { user: { admin: true, password: user.password,
                      password_confirmation: user.password } }
          end
          before { patch user_path(user), params }
          specify { expect(user.reload).not_to be_admin }
        end
      end
    end

But when i do the test, it doesn't work. Then I check the log file, it turns that
the remember_token changed so the method 'signed_in_user' worked, then the page redirect
to the 'sign in' page. So the right code should be like below:

    require 'spec_helper'

    describe "User pages" do
      .
      .
      .
      describe "edit" do
        .
        .
        .
        describe "forbidden attributes" do
          let(:params) do
            { user: { admin: true, password: user.password,
                      password_confirmation: user.password } }
          end
          before do
            sign_in user, no_capybara: true
            patch user_path(user), params
          end
          specify { expect(user.reload).not_to be_admin }
        end
      end
    end

counter_cache for followers and followed_users

Hello,

I'm trying to add a counter_cache for both followers and followed_users because I'm using Ransack to have a searchable, sortable users table in the users/index.html.erb view. I'm able to get a counter_cache to work for the followed_users/relationships association. But with similar code in the migration for the followers/reverse_relationships, the counts all come out as 0 when they shouldn't.

Would you know if having a counter_cache would be possible in this situation?

Here is the migration that half works:

class AddFollowersCountAndFollowedCountToUsers < ActiveRecord::Migration
  def up
    add_column :users, :reverse_relationships_count, :integer, default: 0, null: false
    add_column :users, :relationships_count, :integer, default: 0, null: false

    User.find_each(select: 'id') do |result|
      User.reset_counters(result.id, :reverse_relationships)
      User.reset_counters(result.id, :relationships)
    end
  end

  def down
    remove_column :users, :reverse_relationships_count
    remove_column :users, :relationships_count
  end
end

cannot load such file -- guard/guard (LoadError)

$ rails generate integration_test static_pages
home/wuhlcom/.rvm/gems/ruby-2.3.1@rails_4_0/gems/guard-rspec-2.5.0/lib/guard/rspec.rb:2:in `require': cannot load such file -- guard/guard (LoadError)
除了Ruby版本,这个是按你的教程第3章做的,找不到guard/guard Gemfile和你的一模一样

[wuhlcom@localhost sample_app]$ cat -n Gemfile

     1 source 'https://rubygems.org'
     2  ruby '2.3.1'
     3  
     4  gem 'rails', '4.0.8'
     5  
     6  group :development, :test do
     7    gem 'sqlite3'
     8  
     9    gem 'rspec-rails', '2.13.1'
    10   # gem 'rspec-rails', '3.3.2'
    11    
    12   gem 'guard-rspec', '2.5.0'
    13  # gem 'guard-rspec', '4.6.0'
    14   
    15    gem 'spork-rails', '4.0.0'
    16   
    17    gem 'guard-spork', '1.5.0'
    18   # gem 'guard-spork', '1.5.1'
    19    gem 'childprocess', '0.3.6'
    20  end
    21  
    22  group :test do
    23    gem 'selenium-webdriver', '2.35.1'
    24    gem 'capybara', '2.1.0'
    25  
    26     # Uncomment this line on OS X.
    27     # gem 'growl', '1.0.3'
    28     
    29      # Uncomment these lines on Linux.
    30     gem 'libnotify', '0.8.0'
    31     
    32     # Uncomment these lines on Windows.
    33     # gem 'rb-notifu', '0.0.4'
    34     # gem 'win32console', '1.3.2'
    35     # gem 'wdm', '0.1.0'
    36  end
    37  
    38  gem 'sass-rails', '4.0.1'
    39  gem 'uglifier', '2.1.1'
    40  gem 'coffee-rails', '4.0.1'
    41  gem 'jquery-rails', '2.2.1'
    42  gem 'turbolinks', '1.1.1'
    43  gem 'jbuilder', '1.0.2'
    44  
    45  group :doc do
    46    gem 'sdoc', '0.3.20', require: false
    47  end
    48  
    49  group :production do
    50    gem 'pg', '0.15.1'
    51  end

Chapter 12 - console commands

I'm using cloud9 for development & found two places where "rails db:migrate" is used. Similarly "rails test" is used 4 times. Neither of which executes for me in my c9.io command line. Might be a fluke of their configuration, thought I'd mention - by now - I know how to deal with it.

Context:

Chapter 12 - https://www.railstutorial.org/book/password_reset

My repo - https://github.com/Mirv/railstut-01

Sidenote: Bought your book last year from amazon, thank you for the awesome work!

PS: Had to muck about in the gemfile some and eventually found somehow the page was corrupt in order to get ruby 5 to update. The "rails" command works just fine as it's a version change to Ruby on Rails, not a conflict with cloud9.

Add test for 'sign out' but it fails

In local web server, I find that sign out a user works well on a browser.
But in test, it failed.

I added this to the user_pages_spec.rb

require 'spec_helper'
describe "User pages" do

  describe "sign out" do
    let(:user) { FactoryGirl.create(:user) }
    before :each do
      sign_in user
    end

    it "should sign out a user" do
      delete signout_path
      expect(page).to have_content("Sign in")
    end
  end
end

Unfortunately, it failed the test. Maybe I did something wrong?

Accounts dropdown menu

Upon loading the repository into local server, there's error display on local port about application.html line 7, the part where it tags application for javascript, reverting it to default is passable but accounts dropdown menu stops working. There is already a stopic specifically for the issue, that explains how to solve the issue, but for the daft- me- could you solve it.

Overwriting core methods is a bad practice

This commit defines User.hash, which overwrites the Object#hash method.

Overwriting core methods can lead to unexpected behaviours, like the one showed here.

I suggest to rename it to something like digested_token; it seems to me the most idiomatic name.

Cucumber error.

Hello, can you help me to find out the problem. Somehow, when I try to start this command "cucumber features/" I've got an error: " undefined method visit' for #<Object:0x007fc6d226b970> (NoMethodError) ./features/step_definitions/authentication_steps.rb:2:in/^a user visits the signin page$/'
features/sing_in.feature:8:in `Given a user visits the signin page'"

I've even say in steps the page
"
Given /^a user visits the signin page$/ do
visit '/signin'
end
"

Btw. If I set like this
"
Given /^a user visits the signin page$/ do
visit signin_path
end
"

I've got another error:
"
Given a user visits the signin page
undefined local variable or method signin_path' for #<Object:0x007fa7894a3a20> (NameError) ./features/step_definitions/authentication_steps.rb:2:in/^a user visits the signin page$/'
features/sing_in.feature:8:in `Given a user visits the signin page'
"

Thanks

current_user is nil when not signed in and clicking on following/followers raises exception

If you are not signed in and you navigate to /users/1, and try to click on following/followers links under the user name and gravatar, the _user.html.erb partial tries to determine if the current_user is an admin, calling the admin? method on a nil object. I added "!current_user.nil? &&" to the predicate in my project, but I was wondering if this issue was due to a mistake I made or if this happens with everyone...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.