ruby-on-rails-3.2

Capistrano deploy - assets precompile error

ⅰ亾dé卋堺 提交于 2019-12-07 06:44:49
问题 I am deploying with Capistrano to my new VPS. After the first deploy(cap deploy) everything was OK (site was running), but the second deploy failed on assets:precompile error. I am running rails 3.2.13, ruby 2.0.0, rvm. error: * executing "cd -- /home/rails/releases/20140116121250 && RAILS_ENV=production RAILS_GROUPS=assets bundle exec rake assets:precompile" servers: ["IP"] [IP] executing command *** [err :: IP] bash: line 1: 23406 Killed RAILS_ENV=production RAILS_GROUPS=assets bundle exec

Can't mass-assign protected attributes attr_accessor and attr_accessible

柔情痞子 提交于 2019-12-07 05:55:51
问题 in rails 2.3.11 , I have below in model attr_accessor :person_id and in controller @project.person_id = current_user.id now, I am converting this in rails 3.2.11 and I am getting Can't mass-assign protected attributes: person_id so I changed in model, I removed :person_id from attr_accessor and add below line attr_accessible :person_id but I am uisng person_id in controller, here it is @project.person_id = current_user.id I am getting this now NoMethodError in ProjectsController#create

Rails: change default sender in action mailer

醉酒当歌 提交于 2019-12-07 05:46:07
问题 I am sending email using action mailer in my rails app. But it allows only one default sender. This is my UserMailer class: class UserMailer < ActionMailer::Base default :from => "example@example.com" def welcome_email(user, order) @user = user @order = order mail(:to => user.email, :subject => "Your Order") end def signup_email(user) @user = user mail(:to => user.email, :subject => "Thank you.") end def invite_confirm(curuser,usemail,post) @greeting = "Hi" @user = curuser @post = post mail(

Getting fields_for to work with has_many relationship

人走茶凉 提交于 2019-12-07 05:08:06
问题 I'm having trouble generating a nested model form. Here are my models: class Workout < ActiveRecord::Base has_many :scores has_many :users, :through => :scores accepts_nested_attributes_for :scores end class Score < ActiveRecord::Base belongs_to :user belongs_to :workout end class User < ActiveRecord::Base has_many :scores has_many :workout, :through => :scores end In the Workout controller, here's what I have for the new action: def new @workout = Workout.new 3.times { @workout.scores.build

Rails 3.2 - collection_select Adding A Null Entry In The First Position Of My Array

試著忘記壹切 提交于 2019-12-07 02:52:32
I have a Ruby on Rails 3.2.13 application where I have a collection_select statement. The collection_select statement is in a fields_for statement where I gather selected ids from the collection_select and use them to populate another table. The problem I am having is that the collection_select statement adds a null id entry in the array that stores the collection of selected ids. Here is my code in my view: <%= f.fields_for :media_topics do |media_topic| %> <%= media_topic.label :topic, "Topics" %><%= media_topic.collection_select(:topic_id, Topic.order("name_en"), :id, :name_en, {},

Not getting debug output for view errors in development mode

你离开我真会死。 提交于 2019-12-07 02:33:50
问题 This is very odd. At the moment, I have some kind of error in a view, but can't see what it is. Also, no debug output in the web server trace. The Rails 3.2.2 app is an upgrade from 2.7.10, and I'm using "thin" as my development server. I do get normal debug output when the error occurs in other places. EDIT: I'm running development, as you can see here: => Booting Thin => Rails 3.2.2 application starting in development on http://0.0.0.0:3000 => Call with -d to detach => Ctrl-C to shutdown

Rails - Deleting unsaved associated records

旧街凉风 提交于 2019-12-07 01:06:11
问题 Lets say I have a user model that has many articles. If I call user.articles.new many times I will have many unsaved article objects associated with the user. They are visible when you run user.articles. Calling user.save will save all of this unsaved records. How can I delete unsaved records? I plan on calling user.save but I don't want those unsaved records to be there 回答1: I use the following workaround before_validation :remove_blank_articles! : class User has_many :articles validates

After removing caches_page cached sites are still not updated

℡╲_俬逩灬. 提交于 2019-12-07 00:34:29
I played a bit with caching. I added caches_page :show to my ArticlesController and it causes me terrible pain. I removed the caches_page from the controller but nothing happened. I restarted the server (thin + nginx) but nothing happened. I cleaned the cache via console Rails.cache.clear in production mode and restarted the server again. Now it's working again for the articles I didn't call but the one that were cached are still not refreshed. I already cleaned the cache of my browser but it doesnt help. How can I get rid of this buggie behavior? zsquare Page cache generates an HTML page

Undefined method `tagged' for Formatter error after Rails 4 upgrade

浪尽此生 提交于 2019-12-06 23:31:56
问题 I have upgraded from Rails 3.2 to Rails 4 by following the Ruby Screencast guide. My tests are running and the server starts, yet I receive an error when I send a request: ERROR NoMethodError: undefined method `tagged' for #<Formatter:0x000000057f5dc8> /home/mahoni/.rvm/gems/ruby-2.0.0-p195/gems/activesupport-4.0.0/lib/active_support/tagged_logging.rb:67:in `tagged' /home/mahoni/.rvm/gems/ruby-2.0.0-p195/gems/railties-4.0.0/lib/rails/rack/logger.rb:21:in `call' /home/mahoni/.rvm/gems/ruby-2.0

Virtual attributes and mass-assignment

拥有回忆 提交于 2019-12-06 22:27:52
问题 developers! I can't understand next situation For Example I have model class Pg::City < ActiveRecord::Base belongs_to :country #virtual accessors attr_accessor :population #attr_accessible :city, :isdisabled, :country_id end I can use code like this: c = Pg::City.new({:population=>1000}) puts c.population 1000 But if I uncomment attr_accessible code above throw warning WARNING: Can't mass-assign protected attributes: population How can I use virtual attributes for mass-assigmnment together