railstutorial.org

SessionsHelper in railstutorial.org: Should helpers be general-purpose modules for code not needed in views?

旧巷老猫 提交于 2019-11-28 21:19:03
railstutorial.org has a suggestion which strikes me as a little odd. It suggests this code : class ApplicationController < ActionController::Base protect_from_forgery include SessionsHelper end The include SessionsHelper makes the methods available from ApplicationController , yes, but it makes them available in any view, as well. I understand that authentication/authorization is cross-cutting, but is this really the best place? That seems to me to be potentially too broad of a scope. Putting code which implements, say, a before_filter which conditionally redirects (as the railstutorial.org

Excon::Errors::Forbidden (Expected(200) <=> Actual(403 Forbidden)

限于喜欢 提交于 2019-11-28 19:00:40
When I try to upload a picture to a "Car" object I'm denied access to S3. But the site images that are in the assets folder have displayed just fine since I added S3. The specific error that I get is this: 2015-02-17T14:40:48.459629+00:00 app[web.1]: Excon::Errors::Forbidden (Expected(200) <=> Actual(403 Forbidden) 2015-02-17T14:40:48.459630+00:00 app[web.1]: excon.error.response 2015-02-17T14:40:48.459635+00:00 app[web.1]: "Connection" => "close" 2015-02-17T14:40:48.459637+00:00 app[web.1]: "Content-Type" => "application/xml" 2015-02-17T14:40:48.459639+00:00 app[web.1]: "Date" => "Tue, 17 Feb

Why does my rails rollback when I try to user.save?

一个人想着一个人 提交于 2019-11-28 15:58:14
I have installed the RailsTutorial sample app(the twitter like application) and am trying to understand why the following piece of console code does not update the database when I try updating the user db. I am expecting the user information to get updated once I use the user.save . However, this rolls back to unedited data. Is this due to a user based restriction? Users controller: class UsersController < ApplicationController #before_filter :signed_in_user, only: [:index, :edit, :update, :destroy, :following, :followers] # By default before filters apply to all actions #before_filter

Micropost character countdown (Rails Tutorial, 2nd Ed, Chapter 10, Exercise 7)

邮差的信 提交于 2019-11-28 12:47:11
I attempted the micropost character countdown in The Rails Tutorial (Chapter 10, Exercise 7) using the information here as a base and with some help from StackOverflow answers here and here . On screen, it looks like this , and as you get closer to the character limit, the text gradually turns redder, and once the micropost is overlimit, the Post button disables, finishing like so . The current implementation looks like: views/shared/_micropost_form.html.haml = form_for @micropost do |f| = render 'shared/error_messages', object: f.object .field= f.text_area :content, placeholder: t('.compose

cannot load railtie after upgrade to rails 4 per ruby.railstutorial.org

十年热恋 提交于 2019-11-28 09:35:23
OS is Ubuntu 12.04, 64 bit. New to rails. Relatively new to Ruby. Following the ruby.railstutorial.org tutorial, chapter 3. The tutorial has been updated to use ruby 2.0.0 and Rails 4.0.0.rc1. Previously the gemfile was specifying Rails 3.2.13 and not specifying Ruby version. After moving to the latest Gemfile in the tutorial, ruby 2.0.0 and Rails 4.0.0.rc1, I'm getting the following error when running rails commands. Example here is rails server user@machine:~/bin/railslearn/sample_app$ rails server /home/paul/bin/railslearn/sample_app/config/application.rb:7:in `require': cannot load such

How do I start enterpiseDB PostgreSQL on Mac OSX 10.6.8?

允我心安 提交于 2019-11-28 08:51:07
Mac OSX 10.6.8 The postgres website says postgres 9.2+ is compatible with Mac OSX 10.6+, so I downloaded the 9.2.4 version of the installer for Mac OSX here: http://www.enterprisedb.com/products-services-training/pgdownload I accepted all the defaults, so postgres was installed in the directory: /Library/PostgreSQL/9.2 (If you are installing postgres for rails development, in order to install the pg gem you need to add to your PATH: http://excid3.com/blog/installing-postgresql-and-pg-gem-on-mac-osx/#.UfkImuB6gy5 ) Now, I am trying to figure out how to use postgres. I found a stackoverflow

Error installing Ruby on Rails 4.0 - atomic_reference.c Error 71

巧了我就是萌 提交于 2019-11-28 07:55:59
问题 I am getting an error when trying to install rails (or more specifically, atomic). Building native extensions. This could take a while... ERROR: Error installing rails: ERROR: Failed to build gem native extension. /Users/dima/.rvm/rubies/ruby-2.0.0-p247/bin/ruby extconf.rb creating Makefile make compiling atomic_reference.c atomic_reference.c:50:9: warning: implicit declaration of function 'OSAtomicCompareAndSwap64' is invalid in C99 [-Wimplicit-function-declaration] if

Rails 3 Tutorial Chapter 11 “Validation failed: Email has already been taken” error

。_饼干妹妹 提交于 2019-11-28 07:45:36
My trouble arose in Chapter 11 of the Ruby on Rails Tutorial here . I was seeing this rspec error: Failure/Error: :user => Factory(:user, :email => Factory.next(:email))) ActiveRecord::RecordInvalid: Validation failed: Email has already been taken first in user_spec.rb then in micropost_spec.rb . It was pretty puzzling. I thought the factory statements were generating a user in a fresh testing db each time autotest ran rspec. I checked out source files from the master branch with git and tried again, but saw the same error. I therefore suspected it related to the db contents somehow and not

Session not destroyed when closing browser - RailsTutorial.org

随声附和 提交于 2019-11-28 04:38:15
问题 In working through Michael Hartl's railstutorial.org, I'm in Chapter 8 (specifically 8.2.3). The current problem is implementing a session to keep the user logged in across multiple views, but the functionality implemented in this section is supposed to be a temporary session that expires (logs the user out) when the browser window is closed. Here is the statement from the textbook indicating such: If you quit your browser completely, you should also be able to verify that the application

Global access to Rake DSL methods is deprecated

…衆ロ難τιáo~ 提交于 2019-11-27 17:19:20
I am working through the Ruby on Rails 3 tutorial book and typed the following on the command line: rake db:migrate which produced the following warning. WARNING: Global access to Rake DSL methods is deprecated. Please Include ... Rake::DSL into classes and modules which use the Rake DSL methods. WARNING: DSL method DemoApp::Application#task called at /Users/imac/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/railties-3.0.7/lib/rails/application.rb:215:in `initialize_tasks' I am not sure what to do about it or how to work with it. I don't know any other command for Rake. How can I fix this