Git Product home page Git Product logo

sample_app's People

Contributors

mhartl 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

sample_app's Issues

will paginate

gem 'will_paginate', '3.0.pre2' was not working for me. got this error:
`enable!': uninitialized constant ActiveRecord::Associations::AssociationCollection

I fixed it by using-> gem 'will_paginate', '3.0.pre4'

UsersController :authenticate

The final UsersController the before_filter :authenticate wasn't changed to the :except format so two tests fail.

Just need to change line 2 in ~\app\controllers\users_controller.rb from:

before_filter :authenticate, :only => [:index, :edit, :update, :destroy]

to

before_filter :authenticate, :except => [:show, :new, :create]

Took me almost an hour to finally figure it out.

Admin takes no different value other than default value

I am having issue with admin default value. When ever I run migration and try to add values from console for admin as true it still takes the value for admin as false. It is same for any columns that I add with a default value. It only takes default values for the whole database column. I cannot add any other new value other than the default value. I need help. Can you please respond fast as I need to get this issue resolved really fast for completing my project. :(
Thank you.

Chrome CSS issue

The latest version of Chrome incorrectly renders the top right nav menu, dropping it down to the top of the content div.

Error Showing Posts

undefined method `model_name' for NilClass:Class

Extracted source (around line #16):

13:
14: <% unless @user.microposts.empty? %>
15:


16: <%= render @microposts %>
17:

18: <%= will_paginate @microposts %>
19: <% end %>

rails_sample_app not working in cf-246

Hi,
I have configured cf- 246 release. And deployed rails_sample_app with ruby buildpack version 1.6.27.
Getting Bad request uri in browser.
Error Trace:

-----> Downloaded app package (268K)
-----> Downloaded app buildpack cache (11M)
-------> Buildpack version 1.6.27
Downloaded [file:///var/vcap/data/dea_next/admin_buildpacks/f35bb6e7-24a7-46ae-8f42-6f02ca3f76f5_9d7d4d844353ab40f5d43655a055ef2cca0e8b88/dependencies/https___buildpacks.cloudfoundry.org_concourse-binaries_bundler_bundler-1.13.5.tgz]
-----> Compiling Ruby/Rails
Downloaded [file:///var/vcap/data/dea_next/admin_buildpacks/f35bb6e7-24a7-46ae-8f42-6f02ca3f76f5_9d7d4d844353ab40f5d43655a055ef2cca0e8b88/dependencies/https___buildpacks.cloudfoundry.org_concourse-binaries_ruby_ruby-2.3.1-linux-x64.tgz]
-----> Using Ruby version: ruby-2.3.1
-----> Installing dependencies using bundler 1.13.5
Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment
Your Gemfile lists the gem rspec-rails (= 2.6.1) more than once.
You should probably keep only one of them.
While it's not a problem now, it could cause errors if you change the version of one of them later.
Warning: the running version of Bundler (1.13.5) is older than the version that created the lockfile (1.13.6). We suggest you upgrade to the latest version of Bundler by running gem install bundler.
Fetching gem metadata from http://rubygems.org/...........
Fetching version metadata from http://rubygems.org/..
Fetching dependency metadata from http://rubygems.org/.
Installing abstract 1.0.0
Installing rake 0.9.2.2
Installing builder 2.1.2
Installing activesupport 3.0.12
Installing i18n 0.5.0
Installing rack 1.2.5
Installing tzinfo 0.3.32
Installing polyglot 0.3.3
Installing mime-types 1.18
Installing arel 2.0.10
Installing cf-runtime 0.2.0
Installing gravatar_image_tag 1.0.0.pre2
Installing json 1.6.6 with native extensions
Installing pg 0.15.1 with native extensions
Using bundler 1.13.5
Installing thor 0.14.6
Installing rails_serve_static_assets 0.0.2
Installing rails_stdout_logging 0.0.3
Installing sqlite3 1.3.4 with native extensions
Installing will_paginate 3.0.pre2
Installing erubis 2.6.6
Installing activemodel 3.0.12
Installing rack-mount 0.6.14
Installing rack-test 0.5.7
Installing treetop 1.4.10
Installing cf-autoconfig 0.2.1
Installing rails_12factor 0.0.2
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory:
/tmp/staged/app/vendor/bundle/ruby/2.3.0/gems/json-1.6.6/ext/json/ext/generator
/tmp/staged/app/vendor/ruby-2.3.1/bin/ruby -r ./siteconf20170116-152-c5r1eh.rb
extconf.rb
creating Makefile
current directory:
/tmp/staged/app/vendor/bundle/ruby/2.3.0/gems/json-1.6.6/ext/json/ext/generator
make "DESTDIR=" clean
current directory:
/tmp/staged/app/vendor/bundle/ruby/2.3.0/gems/json-1.6.6/ext/json/ext/generator
make "DESTDIR="
compiling generator.c
In file included from generator.c:1:0:
../fbuffer/fbuffer.h: In function âfbuffer_to_sâ:
../fbuffer/fbuffer.h:151:47: error: macro "rb_str_new" requires 2 arguments, but
only 1 given
VALUE result = rb_str_new(FBUFFER_PAIR(fb));
^
../fbuffer/fbuffer.h:151:20: warning: initialization makes integer from pointer
without a cast [enabled by default]
VALUE result = rb_str_new(FBUFFER_PAIR(fb));
^
In file included from generator.c:2:0:
generator.c: In function âcState_arefâ:
generator.h:96:27: warning: variable âstateâ set but not used
[-Wunused-but-set-variable]
JSON_Generator_State *state;
^
generator.c:632:5: note: in expansion of macro âGET_STATEâ
GET_STATE(self);
^
generator.c: In function âisArrayOrObjectâ:
generator.c:863:10: warning: unused variable âcâ [-Wunused-variable]
char c, *p = RSTRING_PTR(string), *q = p + string_len - 1;
^
make: *** [generator.o] Error 1
make failed, exit code 2
Gem files will remain installed in
/tmp/staged/app/vendor/bundle/ruby/2.3.0/gems/json-1.6.6 for inspection.
Results logged to
/tmp/staged/app/vendor/bundle/ruby/2.3.0/extensions/x86_64-linux/2.3.0-static/json-1.6.6/gem_make.out
An error occurred while installing json (1.6.6), and Bundler cannot continue.
Make sure that gem install json -v '1.6.6' succeeds before bundling.
Bundler Output: Your Gemfile lists the gem rspec-rails (= 2.6.1) more than once.
You should probably keep only one of them.
While it's not a problem now, it could cause errors if you change the version of one of them later.
Warning: the running version of Bundler (1.13.5) is older than the version that created the lockfile (1.13.6). We suggest you upgrade to the latest version of Bundler by running gem install bundler.
Fetching gem metadata from http://rubygems.org/...........
Fetching version metadata from http://rubygems.org/..
Fetching dependency metadata from http://rubygems.org/.
Installing abstract 1.0.0
Installing rake 0.9.2.2
Installing builder 2.1.2
Installing activesupport 3.0.12
Installing i18n 0.5.0
Installing rack 1.2.5
Installing tzinfo 0.3.32
Installing polyglot 0.3.3
Installing mime-types 1.18
Installing arel 2.0.10
Installing cf-runtime 0.2.0
Installing gravatar_image_tag 1.0.0.pre2
Installing json 1.6.6 with native extensions
Installing pg 0.15.1 with native extensions
Using bundler 1.13.5
Installing thor 0.14.6
Installing rails_serve_static_assets 0.0.2
Installing rails_stdout_logging 0.0.3
Installing sqlite3 1.3.4 with native extensions
Installing will_paginate 3.0.pre2
Installing erubis 2.6.6
Installing activemodel 3.0.12
Installing rack-mount 0.6.14
Installing rack-test 0.5.7
Installing treetop 1.4.10
Installing cf-autoconfig 0.2.1
Installing rails_12factor 0.0.2
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory:
/tmp/staged/app/vendor/bundle/ruby/2.3.0/gems/json-1.6.6/ext/json/ext/generator
/tmp/staged/app/vendor/ruby-2.3.1/bin/ruby -r ./siteconf20170116-152-c5r1eh.rb
extconf.rb
creating Makefile
current directory:
/tmp/staged/app/vendor/bundle/ruby/2.3.0/gems/json-1.6.6/ext/json/ext/generator
make "DESTDIR=" clean
current directory:
/tmp/staged/app/vendor/bundle/ruby/2.3.0/gems/json-1.6.6/ext/json/ext/generator
make "DESTDIR="
compiling generator.c
In file included from generator.c:1:0:
../fbuffer/fbuffer.h: In function âfbuffer_to_sâ:
../fbuffer/fbuffer.h:151:47: error: macro "rb_str_new" requires 2 arguments, but
only 1 given
VALUE result = rb_str_new(FBUFFER_PAIR(fb));
^
../fbuffer/fbuffer.h:151:20: warning: initialization makes integer from pointer
without a cast [enabled by default]
VALUE result = rb_str_new(FBUFFER_PAIR(fb));
^
In file included from generator.c:2:0:
generator.c: In function âcState_arefâ:
generator.h:96:27: warning: variable âstateâ set but not used
[-Wunused-but-set-variable]
JSON_Generator_State *state;
^
generator.c:632:5: note: in expansion of macro âGET_STATEâ
GET_STATE(self);
^
generator.c: In function âisArrayOrObjectâ:
generator.c:863:10: warning: unused variable âcâ [-Wunused-variable]
char c, *p = RSTRING_PTR(string), *q = p + string_len - 1;
^
make: *** [generator.o] Error 1
make failed, exit code 2
Gem files will remain installed in
/tmp/staged/app/vendor/bundle/ruby/2.3.0/gems/json-1.6.6 for inspection.
Results logged to
/tmp/staged/app/vendor/bundle/ruby/2.3.0/extensions/x86_64-linux/2.3.0-static/json-1.6.6/gem_make.out
An error occurred while installing json (1.6.6), and Bundler cannot continue.
Make sure that gem install json -v '1.6.6' succeeds before bundling.
!
! Failed to install gems via Bundler.
!
Staging failed: Buildpack compilation step failed

FAILED
BuildpackCompileFailed

Kindly help on this.

no routing matches

I've followed all the tutorial but when I 'm in the listing 12.29 fot test the following and follewers I got this error:

  1. UsersController following pages when not signed in should protect 'following'
    Failure/Error: get :following, :id => 1
    ActionController::RoutingError:
    No route matches {:id=>1, :controller=>"users", :action=>"following"}

    ./spec/controllers/users_controller_spec.rb:10:in `block (4 levels) in <top (required)>'

I don't understand if I have this:

it "should protect 'following'" do
get :following, :id => 1
response.should redirecto_to (new_selector_session_en_path)
end

and my routes :

resources :users do
member do
get :following, :followers
end
resources :favorites
end

Book text error

Not sure if this is the correct place to post this, but List 11.35 needs to be updated with the delete post portion of the code.

Listing 9.25

test "login without remembering" do log_in_as(@user, remember_me: '0') assert_nil cookies['remember_token'] end

The assert_nil line throws an error because cookies.delete (called in the log_in_as helper method under logout(user)) simply sets the value to "" until the browser is closed. Because in Ruby "".nil? is false, the test is not passing.

stuck on chapter 8

current_user redirects to root_path instead of user-path if <%= if signed_in? %>

ActionView::Template::Error (no implicit conversion of nil into String)

Trying to run the sample app, but I'm having several problems.

First, both the json and nokogiri gems don't install cleanly on my machine (Ubuntu 16.04). However, this could be fixed by running bundle update json nokogiri which installs newer versions.

After running rake db:setup, I can now boot the server, however, when visiting localhost:3000 in my browser, I get the following error which I can't figure out:

Started GET "/" for 127.0.0.1 at 2016-07-20 16:10:22 +0300
  Processing by PagesController#home as HTML
  SQL (0.2ms)   SELECT name
 FROM sqlite_master
 WHERE type = 'table' AND NOT name = 'sqlite_sequence'

  User Load (0.1ms)  SELECT "users".* FROM "users" WHERE "users"."id" IS NULL LIMIT 1
  CACHE (0.0ms)  SELECT "users".* FROM "users" WHERE "users"."id" IS NULL LIMIT 1
Rendered layouts/_stylesheets.html.erb (6.5ms)
Rendered pages/home.html.erb within layouts/application (10.5ms)
Completed 500 Internal Server Error in 52ms

ActionView::Template::Error (no implicit conversion of nil into String):
    1: <!--[if lt IE 9]>
    2: <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
    3: <![endif]-->
    4: <%= stylesheet_link_tag 'blueprint/screen', :media => 'screen' %>
    5: <%= stylesheet_link_tag 'blueprint/print',  :media => 'print' %>
    6: <!--[if lt IE 8]><%= stylesheet_link_tag 'blueprint/ie' %><![endif]-->
    7: <%= stylesheet_link_tag 'custom', :media => 'screen' %>
  app/views/layouts/_stylesheets.html.erb:4:in `_app_views_layouts__stylesheets_html_erb___3765224715511223535_47141299130920_2224696984243359482'
  app/views/layouts/application.html.erb:6:in `_app_views_layouts_application_html_erb___916573377981086590_47141299334460__2875086869258066459'

Rendered /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/actionpack-3.0.12/lib/action_dispatch/middleware/templates/rescues/_trace.erb (1.3ms)
Rendered /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/actionpack-3.0.12/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (3.1ms)
Rendered /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/actionpack-3.0.12/lib/action_dispatch/middleware/templates/rescues/template_error.erb within rescues/layout (7.7ms)

Not sure how the line <%= stylesheet_link_tag 'blueprint/screen', :media => 'screen' %> could be trying to convert nil into a String, since there are only constants here.

Chapter 11 - Deleting Micropost

I am having trouble deleting a micropost. Everything worked well until section 11.3.4. I have posted my problem on Stack Overflow http://stackoverflow.com/questions/8236124/routing-error-no-route-matches-get-microposts-304-deleting-a-micropost-m. I also found another user who had similar problems but his solution didn't work for me http://stackoverflow.com/questions/5871875/no-route-matches-error-on-delete-of-micropost-in-chapter-11-of-hartls-ruby-on. I'm running rails on a Windows PC -- this problem might be Windows specific -- and had trouble in the beginning using the rails server command. I was beckoned with an error stating "Could not find a JavaScript runtime." So, in order to overcome this obstacle I commented out the sass-rails, coffee-rails, and uglifier gems and then it worked. However, now I find myself running the same exact code you provide here on Github but the delete function still doesn't work. I'm struggling to find a solution and would love for someone to throw me a lifeline. I'm sure others will come across this problem in the future and it'd be nice to document how to work around this issue. I'd love any insight or guidance from you. Also, thanks a bunch for producing such a intricate and in-depth tutorial!

user url

ther url for user 1 is localhost:3000/users/1....this is tempting to type in say 2, and it will take you to that page, which is good.

But type in 0, or a number above the number of users in the database and you get and ActiveRecord::RecordNotFound error.

How do you redirect to a different page, preferably the users_index_page.

Listing 9.9 has a serious error

After listing 9.9, it says that

newly logged in users are correctly remembered, as you can verify by logging in, closing the browser, and checking that you’re still logged in when you restart the sample application and revisit the sample application. If you want, you can even inspect the browser cookies to see the result directly.

This did not happen for me. I inspected my browser cookies, and saw that the session was the only thing being saved. After a bit of digging, I realised that the log_in method requires

remember(user)

for the above paragraph to work. As it stands now, only newly created users are remembered.

The App doesn't work with heruko

The App doesn't work with heroku since it uses sqlite3 but in Ruby on Rails tutorial we have seen app being deployed on heroku. Is there anything I'm missing?

Reposting tiny bug from getsatisfaction page

Hey, this is alan.m.odonnell from the getsatisfaction page. I think my post about the #current_user= self stuff was kind of unclear, so here's a gist with some code illustrating what I was trying to say.

http://gist.github.com/637811

I've just added a couple lines to #sign_in and #sign_out from the SessionsHelper module that raise an exception unless @current_user is set correctly after calling "current_user = user" and "current_user = nil". Hopefully this is a little clearer!

Having issues when i try to view micropost

undefined method `micropost_path' for #<#Class:0x47a4830:0x47ae7c0>
Extracted source (around line #11):

8:
9: <% if current_user?(micropost.user) %>
10:
11: <%= link_to 'delete', micropost , :method => :delete,
12: :confirm => "You sure?",
13: :title => micropost.content
14: %>

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.