Giter VIP home page Giter VIP logo

rails-generators-readme's People

Stargazers

 avatar  avatar  avatar  avatar

Watchers

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

rails-generators-readme's Issues

Rspec

In spec/features/post_spec.rb, the post instance variable needs a category assigned before testing, since this is required for the view tests

In spec/models/category_spec.rb, the test needs to check respond_to on an instance of the Category class (maybe)

RSpec.describe Category, type: :model do
describe "relations" do
it 'has many posts' do
@category = Category.new
expect(@category).to respond_to(:posts)
end
end
end

Different README

This lab is about "Rails generators" but the README contains notes about "Displaying Associations Rails". I noticed this because I looked up a lab I had completed and it looked totally different. Compare my fork from the previous day. The changes happens on this commit.

Rails Model Generator - rails g model -- Adds application_record.rb

While following along with the code-along, After invoking the following command:
rails g model Author name:string genre:string bio:text --no-test-framework
The following resulted:

      invoke  active_record
      create    db/migrate/20190618010724_create_authors.rb
      create    app/models/application_record.rb
      create    app/models/author.rb

It added an application_record.rb file.
Additionally, class Author inherits from Application Record as such:

class Author < ApplicationRecord
end

I believe the material needs to be updated to reflect the changes in Rails 5. I found some information here: https://blog.bigbinary.com/2015/12/28/application-record-in-rails-5.html
and here: https://stackoverflow.com/questions/37359527/why-rails-5-uses-applicationrecord-instead-of-activerecordbase

I think the material in this lesson should be updated accordingly.
Hoping this will help learn creators to help future learn students.

Delete

NVM, I was reading the wrong part.

Categories spec set up to fail

I added a before hook so there would be a category when it gets :show; otherwise, it won't work.

Also, previous poster is correct about the logic in app/models/post.rb. The rspec for that needs to check for title caps, since that's how the validation works. Updated mine so it passes.

v-000 spec not passing

In the v-000 deployment of this lab there is some logic in the app/modules/post.rb file that Capitalizes The First Letter of the title. The spec is looking for the title to be "My edit". It looks like student keep editing the spec to pass the test. It seems either that logic should be removed, or the spec should be updated.

spec/models/category_spec.rb

Cannot call .new on an instance variable. Currently:
expect(category.new).to respond_to(:posts)
Should be:
expect(Category.new).to respond_to(:posts)

change_post_status_data_type_to_posts

"We can simply add in the change_column method like this: change_column :posts, :post_status, :string and after running rake db:migrate our schema will be updated."

Changing the post_status to string makes the test fail.

ForbiddenArgument error on #update

I kept getting an error after I was done with all my generators and I was able to fix it by changing the update method and adding a new method post_params(*args).

def update
    # @post = Post.find(params[:id])
    # @post.update(params.require(:post))
    # redirect_to post_path(@post)
    @post = Post.find(params[:id])
    @post.update(post_params(:title))
    redirect_to post_path(@post)
  end

private
	
def post_params(*args)
  params.require(:post).permit(*args)
end

This need to be fixed by someone so it won't keep showing errors that are not explained in the readme.

problem with test

A test is improperly written. It should be modified this way:

describe "GET #show" do  
  before do              
    @category = Category.create(name: "hello category")
  end

  it "returns http success" do    
    get :show, {:id => @category.id}
    expect(response).to have_http_status(:success)
  end                    
end

Your spec test in category_spec.rb is wrong.

Hi. The current spec test in category_sec.rb does not work . The class Category will not respond to :posts. It is an INSTANCE of class Category that will respond to :posts. Here is the revised spec test that works.

RSpec.describe Category, type: :model do
describe 'relations' do
it 'has many posts' do
@category = Category.create(name: "NewCategory")
expect(@category).to respond_to(:posts)
end
end
end

Readme and tests???

Readme is different than the fork by quite a margin. Initial tests fail and are confusing in context. Is this intended?

Quick Fix: Add word "bio" as a column in table

Line 4: Add "bio" since example seems to show it along columns for name and genre


Model Generators
This is a generator type that gets used regularly. It does a great job of creating the core code needed to create a model and associated database table without adding a lot of bloat to the application. Let's add a new model to the app called Author with columns name and genre, we can use the model generator with the following CLI command:

rails g model Author name:string genre:string bio:text --no-test-framework

Naming error in testbank

Post.count

=> 4

clickbait = Category.find_by(name: "Clickbait")

=> #

clickbait.posts.count

=> 3

Line 3 in db/seeds.rb:
clickbait = Category.create!(name: "Motivation")

Line 3: in rails console commands, should submit "Motivation" as value, not "Clickbait"
clickbait = Category.find_by(name: "Clickbait")
should be
clickbait = Category.find_by(name: "Motivation") #matching the seed

clickbait.posts.count will then return 3. otherwise it crashes.

Please see attached.
bug

RSpec checks for boolean value of post_status but lab has you set to string

I've submitted an edit to this lesson but it seems more like an issue to me now that I think about it. The lab walks you through changing a column and during that change you set post_status from a boolean to a string. The issue here is that if we do change the column to string type as the lab says, rspec fails because it is looking for a boolean value.

There may need to be a different change_column done or have the rspec check for a string value. Either one of those should fix it up.

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.