ruby-on-rails-3.1

rails 3.1.0 belongs_to ActiveResource no longer working

≯℡__Kan透↙ 提交于 2019-12-07 03:58:42
问题 I am upgrading from rails 3.0.7 to 3.1 and am having trouble getting my tests to pass. The problem occurs when I try to use a stubbed active resource object in a factory. #employee.rb class Employee < ActiveResource::Base; end #task.rb class Task < ActiveRecord::Base belongs_to :employee end #factories.rb Factory.define :employee do |e| e.name "name" end Factory.define :task do |t| t.employee { Factory.stub(:employee) } end On the console and in the spec stubbing an employee works.

Rails 3.1: Sqlite exception

隐身守侯 提交于 2019-12-07 00:33:26
I try to launch really simple Ruby on Rails app on VDS. I use Nginx, Phusion Passenger and Sqlite3. I have root rights. Code of creating project: $ rails new myapplication $ cd /rails_apps/myapplication $ bundle install $ rails generate scaffold Post name:string title:string content:text $ RAILS_ENV=production rake db:migrate I can visit main page, it shows ok. But when i try insert data into DB, i get next: SQLite3::ReadOnlyException: attempt to write a readonly database: INSERT INTO "posts" ("content", "created_at", "name", "title", "updated_at") VALUES (?, ?, ?, ?, ?) How can i fix that?

Heroku / Ruby-on-Rails error: image not precompiling

你离开我真会死。 提交于 2019-12-07 00:08:09
问题 I know that Heroku is running the rake assets:precompile task: -----> Writing config/database.yml to read from DATABASE_URL -----> Preparing app for Rails asset pipeline Running: rake assets:precompile -----> Rails plugin injection Injecting rails_log_stdout Injecting rails3_serve_static_assets -----> Discovering process types Procfile declares types -> (none) Default types for Ruby/Rails -> console, rake, web, worker -----> Compiled slug size is 17.7MB -----> Launching... done And I told it

Rails 3.1, exclude JS files from asset pipeline

梦想与她 提交于 2019-12-06 22:28:08
问题 I know there are a million questions already on this, but I can't get this. I want to include most of my JS files in the asset pipeline, but I have a few I want to load conditionally (or only on certain pages). These are big, complicated files and will never, ever be used by 95% of the users, so I'd rather not have them loaded for every user. One set of JS files is for a calendar, placed in: app/assets/javascripts/calendar So my manifest is set up to include only the top directory (and

What does changing config.assets.version number do?

久未见 提交于 2019-12-06 22:02:36
问题 What does changing config.assets.version number do? I understand that the assets expire (as it is written in the comments) but what does it do in the background? would it delete all the compiled assets? or does it take that version number and uses it somewhere else? 回答1: It will precompile assets with another fingerprints (the code appendend to the file name), making all the client's browsers download the files again. In other words, as you said, it expires the caches in the client's browsers

Why using merge method with scopes isn't working anymore on Rails 3.1?

半腔热情 提交于 2019-12-06 20:57:56
问题 I stumbled upon a wonderful article about scopes on Rails 3+ : http://edgerails.info/articles/what-s-new-in-edge-rails/2010/02/23/the-skinny-on-scopes-formerly-named-scope/index.html You can read there (in 'Crazy Town' section) that it's possible to merge scopes from different models like this : class User < ActiveRecord::Base scope :published, lambda { joins(:posts).group("users.id") & Post.published } end which works just as expected, and allows you to do : User.published.to_sql #=> SELECT

Multi file upload with rails_admin (Carrierwave, Paperclip, Dragonfly)

北城以北 提交于 2019-12-06 20:40:29
I'm looking for a quick solution for multi file upload with rails_admin. Any ideas or solutions out there? The approach I'd take here is to develop a custom action which would include it's own view and controller processing. You can generate a rails_admin plugin with the directions at the top of the page here . And here are some examples of custom actions I've built out: Import Print to PDF The import plugin has a supporting blog article here . This is the file you want to look at where you add your upload behavior inside the :controller instance option. 来源: https://stackoverflow.com/questions

RubyGems error after updating system

不羁岁月 提交于 2019-12-06 20:10:17
问题 When trying to launch the rails console after updating my ruby setup using 'sudo gem update --system', I then try execute the rails console by issuing rails c I get this error: Users/myusername/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:247:in `to_specs': Could not find json (~> 1.4) amongst [Ascii85-1.0.1, abstract-1.0.0, actionmailer-3.1.1, actionmailer-3.1.0, actionmailer-3.0.9, actionmailer-3.0.5, actionmailer-3.0.3, actionpack-3.1.1, actionpack-3.1.0,

Precompiled CSS not found in Rails 3.1 production mode

若如初见. 提交于 2019-12-06 17:10:37
问题 When I start up rails in production mode, it precompiles all the assets but is unable to serve the application.css asset. I looked in public/assets and the precompiled application.css exists. However, I get a 404 whenever I try to access it from the page. These are the instructions I use to launch the server, if that may help at all. RAILS_ENV=production bundle exec rake assets:clean RAILS_ENV=production bundle exec rake assets:precompile rails -e production 回答1: If you want Rails to serve

Jquery-ui doesn't work on Heroku, but on localhost yes

青春壹個敷衍的年華 提交于 2019-12-06 16:56:25
I have an app and I use there the autocomplete gem. It works me great on localhost. But when I deploy this app to Heroku, the autocomplete plugin doesn't works me. No errors in Firebug, just nothing. Does anyone an idea, where could be a problem? This is how look my Gemfile : source 'http://rubygems.org' gem 'rails', '3.1.2' # Bundle edge Rails instead: # gem 'rails', :git => 'git://github.com/rails/rails.git' gem 'mysql2' gem "rvm", "~> 1.9.2" gem 'authlogic' gem "rake", "0.8.7" gem 'json' gem "declarative_authorization", "~> 0.5.3" gem "ancestry", "~> 1.2.4" gem "taps", "~> 0.3.23" gem