Git Product home page Git Product logo

intro-to-rails's People

Contributors

benstafford avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

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

intro-to-rails's Issues

FactoryGirl

It took me a while to figure out that MEAP code examples like Factory(:user... are deprecated.

In looking at working code in my blogee I found 3 different ways FactoryGirl is used:

  1. post_1 = FactoryGirl.create(:post, ...)
  2. let!(:post) {create(:post, published:true)}
  3. @post = FactoryGirl.create(:post)

What are the distinctions between these 3 statements?

Dave

Unable to find link Edit Comment running editing comments rspec

running the editing comments rspec, I am getting

  1. Editing comments with invalid attributes
    Failure/Error: click_link "Edit Comment"
    Capybara::ElementNotFound:
    Unable to find link "Edit Comment"

    ./spec/editing_comments_spec.rb:11:in `block (2 levels) in <top (required)>'

  2. Editing comments with valid attributes
    Failure/Error: click_link "Edit Comment"
    Capybara::ElementNotFound:
    Unable to find link "Edit Comment"

    ./spec/editing_comments_spec.rb:11:in `block (2 levels) in <top (required)>'

So the rspec has this in it:

visit posts_path
click_link post.title
click_link comment.author
click_link "Edit Comment"

but on the rendered web page after clicking a post title link I see:
/start of web page

my second post
Edit Post Delete Post Example comment

By: Dave

22 Apr 13:20

my second post content

Add Comment

/end of web page

First, I don't see how the 'click_link comment.author' in the rspec is passing, as there is no such link on the page.

Second, there is no Edit Comment on the page.

So what am I missing here?

It seems that the /comments/show..html.erb is not getting rendered?

Dave

permissions error when trying to install gems

When I type
'gem install bundler'

I get this:
'ceeblet [ ~ ]$ gem install bundler
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.
'
I've done some searching on the net about this error.

Even though I have rbenv installed it looks like the system installation of ruby is always used. I've put shims in the beginning of my path, and I tried to use

rbenv global 2.0.0p247

thinking that would force the use of the shims version but i guess since they are both the same version it isn't working. I've set my path so that shims comes first. I don't know how to force the use of the shims version.

I thought about explicitly setting a GEMS_HOME variable but then thought that might not be good if I am still using the system version of ruby.

Any help would be appreciated.
Thanks.

Here are a few more things for informational purposes:

I am on Mac OSX 10.9.2

ceeblet [ ~ ]$ echo $PATH
/Users/ceeblet/.rbenv/shims:/Users/ceeblet/.rbenv/bin/:/Library/Frameworks/Python.framework/Versions/3.3/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
ceeblet [ ~ ]$

ceeblet [ ~ ]$ which ruby
ruby is /Users/ceeblet/.rbenv/shims/ruby
ruby is /usr/bin/ruby

ceeblet [ ~ ]$ /Users/ceeblet/.rbenv/shims/ruby -v
ruby 2.0.0p247 (2013-06-27 revision 41674) [universal.x86_64-darwin13]
ceeblet [ ~ ]$ /usr/bin/ruby -v
ruby 2.0.0p247 (2013-06-27 revision 41674) [universal.x86_64-darwin13]
ceeblet [ ~ ]$

ceeblet [ ~ ]$ gem environment
RubyGems Environment:

  • RUBYGEMS VERSION: 2.0.3
  • RUBY VERSION: 2.0.0 (2013-06-27 patchlevel 247) [universal.x86_64-darwin13]
  • INSTALLATION DIRECTORY: /Library/Ruby/Gems/2.0.0
  • RUBY EXECUTABLE: /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby
  • EXECUTABLE DIRECTORY: /usr/bin
  • RUBYGEMS PLATFORMS:
    • ruby
    • universal-darwin-13
  • GEM PATHS:
    • /Library/Ruby/Gems/2.0.0
    • /Users/ceeblet/.gem/ruby/2.0.0
    • /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/gems/2.0.0
  • GEM CONFIGURATION:
    • :update_sources => true
    • :verbose => true
    • :backtrace => false
    • :bulk_threshold => 1000
  • REMOTE SOURCES:

Blogee: Failure / Error: visit posts_path

I'm receiving this error and need help determining what direction to take.

screen shot 2014-04-14 at 8 14 20 pm 1

My index.html.erb

<%= link_to "New Post", new_post_path %>
<%= link_to "My Post", post_path(post) %>

Messed up db, not sure how to correct it

I realized that I had generated my comment model without the reference to post, and was trying to correct that issue. I rolled back the previous migration and applied the change (or so I thought), but I am getting an error when I db:migrate.
The error follows:
== 20140424001456 AddPostRefToComments: migrating =============================
-- add_reference(:comments, :post, {:index=>true})
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:

PG::DuplicateColumn: ERROR: column "post_id" of relation "comments" already exists
: ALTER TABLE "comments" ADD COLUMN "post_id" integer/home/action/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.1.0/lib/active_record/connection_adapters/postgresql/database_statements.rb:128:in
`async_exec'

At this point, I've tried quite a few things and likely have the db in a fairly crazy state. I committed my change and pushed up to my repository as "messed up the db". Can you take a peek and let me know how to proceed to correct my issue?

Thanks!

cant close or save files in nitrous

1)I can't close or save open files in my nitrous ide for the last 2 days.
I click on the x by the file name in the tab, or the star, and nothing happens.
I have restarted my nitrous virtual machine it has not resolved the problem.

What do I need to do to resolve this problem?

2)Are the email ID's of the students in the class posted somewhere in this github?

Dave

good git resource.

Version control is a good skill to have for any software development. The tools we use now are more powerful then the days of cvs and visual source safe. Of course, with power come new concepts and added complexity. And I would argue git is probably the most complex and powerful of the new version control system. This book helps. I got what I needed by scanning it, and it makes for a nice reference when unexpected situations arise.

http://git-scm.com/book

But more importantly, over time you will develop habits of dealing with the various situations that arise. Practice makes perfect.

Koans - about_hashes / line 40

  def test_changing_hashes
    hash = { :one => "uno", :two => "dos" }
    hash[:one] = "eins"

    expected = { :one => __, :two => "dos" } #line 39
    assert_equal __, hash #line 40

    # Bonus Question: Why was "expected" broken out into a variable
    # rather than used as a literal?
  end

I'm assuming that we need to fill in both blanks for this to pass.

  • Based on what I see in this method, the value of :one is changed from "uno" to "eins"
  • The blank in line 39 should be filled in with "eins" which would require the blank in line 40 to equal { :one => "eins", :two => "dos" }. Is this right? If so, why doesn't the test pass?

Capybara::ExpectationNotMet

I got this error in creating posts spec and found similar but slightly different code in the book (pictured above). Without solving this issue I passed to the next scenario.

alert

Now I have a similar error in viewing posts spec and anticipate I will do this at least twice more so I thought I'd submit an issue and get some feedback please.

title

Stuck - NoMethodError Undefined method 'post=' when running spec

When running the spec for viewing comments, I'm running into a "NoMethodError - undefined method `post=' ". If I understand correctly, the "post=" is supposed to indicate this is a comment nested to the parent post, right? I'm stuck getting this factory to work.

Also getting this same error on the editing comments spec that was provided.

This is the start of the factory for the viewing comments spec I wrote:

feature "Viewing comments" do
  before do
    # setup everything you need - in this case, probably a good idea to set up
    # two Posts, each with 1 Comment
    post_1 = FactoryGirl.create(:post, title: "This is a post", content: "This is the content of my post", author: "Karl")
    FactoryGirl.create(:comment, post: post_1, content: "Looks like a good time.", author: "James Bond")

end

and here is the error in detail:

Failures:                                                                                                                                                                      

  1) Viewing comments Viewing comments for a post                                                                                                                              
     Failure/Error: FactoryGirl.create(:comment,                                                                                                                               
     NoMethodError:                                                                                                                                                            
       undefined method `post=' for #<Comment:0x000000074f1bc0>                                                                                                                
     # ./spec/features/viewing_comments_spec.rb:8:in `block (2 levels) in <top (required)>'                                                                                    

Finished in 0.29411 seconds                                                                                                                                                    
1 example, 1 failure                                                                                                                                                           

Failed examples:                                                                                                                                                               

rspec ./spec/features/viewing_comments_spec.rb:19 # Viewing comments Viewing comments for a post                                                                               

MEAP question about the argument t on adobe page 14

Code on the page (paste loses the indents):

class CreatePurchases < ActiveRecord::Migration
def change
create_table :purchases do |t|
t.string :name
t.float :cost
t.timestamps
end
end
end

Regarding 'do |t|', what is the value of t in this class?
Is it the last value processed, i.e. the symbol :purchases?
Or what?
Dave

Can't get form nested attribute to work - need help

I have wasted many hours on this....

Hopefully Jim/Ben you still have access to my Nitrous.

My app is workspace/lpl

My main model is Plates which can have many Translations.

If you goto the home page it will list all the plates in the DB ok.

Click 'New plate' upper left will take you to a form to input a new plate.

At the bottom of the form is a translation text area.

If you fill in all the form fields (except the plate image one) and click Save, currently you will get this error:

ActiveRecord::UnknownAttributeError in PlatesController#create
unknown attribute: translation
Extracted source (around line #24):

 if plate_params[:meaning] then vote = 1 else vote = 0 end
22 puts plate_params
23 @plate = Plate.new(plate_params.merge(user_id: 1, rated_count: 1, rating: 
24 :input_rating, translation_votes: vote, translations_attributes: [ { plate_id: :id, user_id: 1,
25 votes: 1 }]))
26 # @plate = Plate.new(plate_params.merge(user_id: 1, rated_count: 1, rating: 27 :input_rating, #translation_votes: vote, translations_attributes: [ { plate_id: :id }, { user_id: 1 },
# { meaning: :meaning }, { votes: 1 }]))

Rails.root: /home/action/workspace/lpl
Application Trace | Framework Trace | Full Trace

app/controllers/plates_controller.rb:24:in `create'

Request

Parameters:

{"utf8"=>"โœ“",
 "authenticity_token"=>"WnuNNO1TtUgdZzpf4RFWkSfXBgPcyKb4GNlZm3SD0Ew=",
 "plate"=>{"plate_number"=>"TCB 7",
 "state"=>"OH",
 "input_rating"=>"1",
 "translation"=>{"meaning"=>"Initials"}},
 "save"=>"Save"}

This is just the latest error of a long string of errors which I have resolved or bypassed.

The fundamental problem is I cannot get the 'Translation' form input field into my translation record as the 'meaning' field. No matter what I have tried.

Hoping you can figure this one out for me.

Thanks.

Dave

Stuck in Koans Error Message

What to do? Keep getting the following:

/home/action/ruby_koans/koans/about_array_assignment.rb:46: untermi                                                            
/home/action/ruby_koans/koans/about_array_assignment.rb:46: syntax                                                             
        from /home/action/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site                                                            
        from path_to_enlightenment.rb:9:in `<main>'                                                                            
rake aborted!                                                                                                                  
Command failed with status (1): [/home/action/.rvm/rubies/ruby-2.0.                                                            
/home/action/ruby_koans/Rakefile:82:in `block in <top (required)>'                                                             
Tasks: TOP => default => walk_the_path                                                                                         
(See full trace by running task with --trace)

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.