ruby-on-rails-3.1

Rails 3.1 serving images from vendor/assets/images

自作多情 提交于 2019-11-30 10:24:19
问题 I am trying to put some external images (used by a jQuery plugin) to vendor/assets/images in my Rails 3.1 app. Problem is that when I try something like: <%= image_tag "ui-bg_flat_75_ffffff_40x100.png" %> I get an error: No route matches [GET] "/assets/ui-bg_flat_75_ffffff_40x100.png" I checked my Rails.application.config.assets.paths and it list these dirs: ..../app/assets/images ..../app/assets/javascripts ..../app/assets/stylesheets ..../vendor/assets/images ..../vendor/assets/stylesheets

RunTimeError: ActionController::RackDelegation in rspec 2.10.1 for rails 3.1.4 application controller

只谈情不闲聊 提交于 2019-11-30 09:24:32
In our rails 3.1.4 app, rspec is used to test the public method require_signin in application controller. Here is the method require_signin: def require_signin if !signed_in? flash.now.alert = "Log in first!" redirect_to signin_path end end Here is the rspec code: it "should invoke require_signin for those without login" do controller.send(:require_signin) controller {should redirect_to signin_path} end The above rspec generates gigantic multi pages error starting like the below: RuntimeError:←[0m ←[31mActionController::RackDelegation#status= delegated to @_response.status=, but @_response is

scheduling a job every minute Rails 3.1 on Heroku

三世轮回 提交于 2019-11-30 09:17:22
I want to run a task every minute on Heroku to check if conditions are met to time-out certain user tasks. I can only run a Heroku cron job every hour, so what's the best way to set up a timed task like this. I am using Rails 3.1 on Heroku. You could use delayed_job with a self-restarting job with a :run_at . Something sort of like this: class YourJob def do_interesting_things #... Do what needs to be done. self.delay(:run_at => 1.minute.from_now).do_interesting_things end def self.start_me_up new.do_interesting_things end end And then somewhere during your application's initialization:

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

落爺英雄遲暮 提交于 2019-11-30 08:34:17
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 activesupport-3.0.7 in any of the sources (Bundler::GemNotFound) Exception class: PhusionPassenger:

Assets say “not precompiled” when they are precompiled

家住魔仙堡 提交于 2019-11-30 08:28:11
Ok so, I'm getting this error when I try to use the asset pipeline. I don't understand what's causing it. Sprockets::Helpers::RailsHelper::AssetPaths::AssetNotPrecompiledError in Photos#show Showing .../app/views/photos/_photo_view.html.haml where line #2 raised: jquery.autocomplete isn't precompiled Extracted source (around line #2): 1: - content_for :scripts do 2: = javascript_include_tag 'jquery.autocomplete' However, this IS precompiled. I ran rake assets:precompile RAILS_ENV=production before starting the server, and in my public/assets directory I have the file: jquery

Sprockets encoding error on js file: invalid UTF-8 byte sequence

烈酒焚心 提交于 2019-11-30 08:27:16
A Sprockets::EncodingError exception is thrown when I include a file with characters that are valid utf-8. The line in question is: * Copyright (c) 2010 - 2011 Johan Säll Larsson If I replace the ä character, the problem goes away, but I don't want to have to remember to edit this vendor file everytime I update it. How can I fix this? I found the solution via the comments on this Sprockets issue : I simply saved the file as utf-8, (TextMate has an option to do this when you chose 'Save As'), and the problem went away. The commenter @shedd also created a useful rake task to find assets which

Time.use_zone is not working as expected

末鹿安然 提交于 2019-11-30 08:18:23
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 This should work ok: Time.use_zone('Hawaii') do p Time.zone.now end Try using Time.now.in_time_zone inside your block instead. > Time.use_zone('Hawaii') do > Time.now.in_time_zone > end => Tue, 03 Jan 2012 13:07:06 HST -10:00 Use Time.current if you want now with timezone support. Time.now is dangerous when

Using Less in a Rails 3.1 App

拟墨画扇 提交于 2019-11-30 08:12:27
I've just upgraded my application to the latest release of rails (3.1) and I'm wanting to integrate Twitter's Bootstrap into my application but it uses LESS and not SASS which is what Rails 3.1 uses by default. How do I go about configuring Rails to use Less instead of Sass? As apneadiving points out, Sprockets (what Rails 3.1 uses for its asset pipeline) supports LESS. To configure your Rails app to support LESS, you can add the gem to the assets group of your Gemfile: group :assets do gem 'less' end Then, run bundle install to get the less gem and its dependencies (which includes the libv8

How to add confirm message with link_to Ruby on rails

核能气质少年 提交于 2019-11-30 08:03:49
I wanted to add confirmation message on link_to function with Ruby. = link_to 'Reset message', :action=>'reset' ,:confirm=>'Are you sure?' Any ideas why it's not working? First, you should verify that your layout have jquery_ujs . Best practice to do it by including it in your main application.js : //= require jquery_ujs Check that you included application.js in your layout: = javascript_include_tag :application While, in development mode, view your source html and verify jquery_ujs.js exists. Run your server and verify your link tag has data-confirm value, for example: <a href="/articles/1"

undefined method `database_authenticatable' for #<ActiveRecord::ConnectionAdapters::TableDefinition:0x9dee690>

心不动则不痛 提交于 2019-11-30 08:01:57
I am using Active Admin gem for my small application based on Quiz. But when I execute rake db:migrate it gives me error. Following is the trace of the command : $ rake db:migrate RAILS_ENV=production --trace ** Invoke db:migrate (first_time) ** Invoke environment (first_time) ** Execute environment ** Invoke db:load_config (first_time) ** Invoke rails_env (first_time) ** Execute rails_env ** Execute db:load_config ** Execute db:migrate == DeviseCreateAdminUsers: migrating ========================================= -- create_table(:admin_users) rake aborted! An error has occurred, all later