ruby-on-rails-3.1

Phusion Passenger is throwing errors after upgrading Ruby and Rails using rvm

强颜欢笑 提交于 2019-12-18 12:56:18
问题 I recently upgraded my Rails setup to 3.1.3 and I'm having issues with Phusion Passenger loading an older app on this server. I got everything running on a testapp but I'm still having issues with this one app. When I run the Webrick server on port 3000 my app runs perfectly but when attempting to access it through the virtual host I continue to get Passenger errors. Here's the info: Error being thrown by Passenger Ruby (Rack) application could not be started Error message: Could not find

Rails v2.3 : Difference between session and cookies

十年热恋 提交于 2019-12-18 12:55:08
问题 I am learning Rails by reading the online guide(for Rails v2.3 ). The guide is great, however, there is a confusion for me, that's: there is a chapter explains the Session of Rails and another chapter explains Cookies of Rails. The explanation is easy to understand separately, but when compare the two, reader like me does not see the significant difference between Session and Cookies . Especially under which situation session should be used and under which situation Cookies should be used ?

Time.use_zone is not working as expected

核能气质少年 提交于 2019-12-18 12:53:20
问题 So right now it is 2:54 PM PST in San Francisco. For some reason, this code block is not returning 12:54 PM HST in Hawaii. Am I missing something here? I would expect this code to return me the current time in Hawaii Time.use_zone('Hawaii') do Time.now end # => 2012-01-03 14:54:54 -0800 回答1: This should work ok: Time.use_zone('Hawaii') do p Time.zone.now end 回答2: Try using Time.now.in_time_zone inside your block instead. > Time.use_zone('Hawaii') do > Time.now.in_time_zone > end => Tue, 03

carrierwave - rails 3.1- undefined method: image_will_change

混江龙づ霸主 提交于 2019-12-18 12:14:41
问题 I get an error that look like this: undefined method `post_image_will_change!' for #<Post:0xf4e9184> app/controllers/posts_controller.rb:43:in `new' app/controllers/posts_controller.rb:43:in `create' I've included this in my "post" model: attr_accessible :title, :name, :content, :post_image mount_uploader :post_image, PostImageUploader and in _form.html.erb I've added: :html => { :multipart => true } I looked CarrierWave Error but that doesn't help me. Any clues of what generates that error?

How to remove “bundle install” command during the project creation in Rails 3.1?

帅比萌擦擦* 提交于 2019-12-18 12:12:35
问题 I am creating a new project: rails new ggg --database=mysql and get following output: create create README create Rakefile create config.ru create .gitignore create Gemfile create app create app/assets/images/rails.png create app/assets/javascripts/application.js create app/assets/stylesheets/application.css create app/controllers/application_controller.rb create app/helpers/application_helper.rb create app/mailers create app/models create app/views/layouts/application.html.erb create app

rvm install: ruby installation error

假如想象 提交于 2019-12-18 11:57:57
问题 I want to install ruby on my Linux Mint 12. I am following this tutorial and this one. when I run rvm install 1.9.3 I see this error: Installing Ruby from source to: /usr/share/ruby-rvm/rubies/ruby-1.9.3, this may take a while depending on your cpu(s)... ruby-1.9.3 - #fetching ruby-1.9.3 - #extracting ruby-1.9.3- to /usr/share/ruby-rvm/src/ruby-1.9.3 ERROR: Error running 'bunzip2 < '/usr/share/ruby-rvm/archives/ruby-1.9.3-.tar.bz2' | tar xf - -C /usr/share/ruby-rvm/tmp/rvm_src_4428', please

Rails respond_with acting different in index and create method

我只是一个虾纸丫 提交于 2019-12-18 11:48:05
问题 I am building a simple json API in Rails 3.1. I created a controller that has two functions: class Api::DogsController < ActionController::Base respond_to :json, :xml def index respond_with({:msg => "success"}) end def create respond_with({:msg => "success"}) end end In routes.rb I have namespace :api do resources :dogs end When I make a get request to http://localhost:3000/api/dogs I get the correct json from above. When I make a post to the same url, I get a rails exception: ArgumentError

Rails 3.1: Determine if asset exists

岁酱吖の 提交于 2019-12-18 10:32:23
问题 Is there a built-in way to determine if an asset exists without resorting to File.exists?(File.join(Rails.root, "foo", "bar", "baz")) and that looks through the asset paths. My app goes and fetches images from a remote server on a Resque queue; until we have the image downloaded I want to serve a placeholder image. Currently I'm using File.exists ... but this means hard-coding a path, which sucks, or looking through the configured asset paths. It seems like this should be there already, but I

Rails 3.1 - Pushing to Heroku - Errors installing postgres adapter?

回眸只為那壹抹淺笑 提交于 2019-12-18 10:06:08
问题 I just upgraded to Rails 3.1 and the first app i've tried to deploy to Heroku has encountered a problem relating to Postgres adapter. I'm able to push the app to heroku but then when i try to migrate the database i get the following error: heroku rake db:migrate rake aborted! Please install the postgresql adapter: `gem install activerecord-postgresql-adapter` (pg is not part of the bundle. Add it to Gemfile.) Tasks: TOP => db:migrate => db:load_config (See full trace by running task with -

facebook open graph crawler triggering json response in rails actions

回眸只為那壹抹淺笑 提交于 2019-12-18 08:00:19
问题 For some reason the facebook crawler is triggering the json response in my rails actions. This causes the action to just return a json representation of the object, without the normal html markup + open graph tags. I have tested this with rails 3.2.6. I use the facebook open graph debugger to see what the scraper is seeing: http://developers.facebook.com/tools/debug. The code is very simple. Imagine a simple "show" action for an object, for example a User. It ends with: respond_to do |format|