ruby-on-rails-3.2

Rails 3.2 app - Should I use a versioning gem (paper_trail or vestal_versions) or handle it manually?

情到浓时终转凉″ 提交于 2019-12-05 09:18:56
My question: Should I roll my own model versioning or use one of the versioning gems that's already out there? If I should use a gem, which one seems best for this application? Info about my app My app is a simple Checklist app. There are Checklists and Jobs, and I track user responses with Responses and Submissions. The Response tells me what the use said ("Done", with a note "We need more mops.") and the Submission tells me when that particular Checklist was filled out (because there may be many submissions and sets of responses for a given checklist). I'll show my associations below, in

Capistrano deploy - assets precompile error

痴心易碎 提交于 2019-12-05 08:45:06
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 rake assets:precompile command finished in 84187ms *** [deploy:update_code] rolling back * executing

Select tag with multiple values pre-selected - Values inserted manually in database

感情迁移 提交于 2019-12-05 08:28:55
I have a problem, I don't planned my database correctly, so always I need to use 'alternatives'. I want pre-selected multiple values in select_tag. But I'm adding the vacancies 'manually' in table vacancy. My controller: def create @hr_curriculum_generic = HrCurriculumGeneric.new(params[:hr_curriculum_generic]) # Tabela CandidatosxVagas unless params[:vacancy_ids].nil? @vacancies_ids = params[:vacancy_ids] -- my form: @vacancies_ids.each do |vacancy_id| # Armazena os id do curriculum, vaga e do cargo na tabela CandidatosxVagas @candidates_vacancies = CandidatesVacancy.new <% @vacancies =

Rails - Deleting unsaved associated records

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-05 04:36:33
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 I use the following workaround before_validation :remove_blank_articles! : class User has_many :articles validates_associated :articles before_validation :remove_blank_articles! private def remove_blank_articles! self.articles

RSolr::Error::InvalidRubyResponse - 200 OK

孤街醉人 提交于 2019-12-05 03:40:12
I am getting following error even after starting forreman and starting sunspot:solr : RSolr::Error::InvalidRubyResponse - 200 OK Error: <result status="1">java.lang.NullPointerException at org.apache.solr.handler.XmlUpdateRequestHandler.doLegacyUpdate(XmlUpdateRequestHandler.java:129) at org.apache.solr.servlet.SolrUpdateServlet.doPost(SolrUpdateServlet.java:87) at javax.servlet.http.HttpServlet.service(HttpServlet.java:727) at javax.servlet.http.HttpServlet.service(HttpServlet.java:820) at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511) at org.mortbay.jetty.servlet

Virtual attributes and mass-assignment

China☆狼群 提交于 2019-12-05 03:33:57
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 with model attributes? Thanks! Using attr_accessor to add a variable does not automatically add it to

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

时光怂恿深爱的人放手 提交于 2019-12-05 03:24:54
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.0-p195/gems/quiet_assets-1.0.2/lib/quiet_assets.rb:18:in `call_with_quiet_assets' /home/mahoni/.rvm

Rails 3.2: ArgumentError: wrong number of arguments (2 for 1) on create

与世无争的帅哥 提交于 2019-12-05 03:16:11
Trying to create an instance of a model, I get the following error... u = User.create # or .where(...).first_or_create # or .where(...).first_or_initialize ArgumentError: wrong number of arguments (2 for 1) Is anyone having the same problem with Rails 3.2? Have you overloaded your model's initialize method? In my case, I had overloaded it with: def initialize(attributes=nil) ... end Which I had to fix to: def initialize(attributes = nil, options = {}) ... end In Rails 3.2, the commit 7c5ae0a88fc9406857ee362c827c57eb23fd5f95 (Added mass-assignment security :as and :without_protection support to

Google plus insert activity on stream

孤街浪徒 提交于 2019-12-05 02:47:08
问题 Tough time inserting an activity to google plus stream. After referring google developers guide. I found an example for java - https://developers.google.com/+/domains/posts/creating Is there a similar example to execute the activites.insert query using google-api-ruby-client. I followed following steps: Define access to app via omniauth-google-oauth2 GOOGLE_CONSUMER_KEY = google_config['KEY'] GOOGLE_CONSUMER_SECRET = google_config['SECRET'] google_scope = "userinfo.email, userinfo.profile,

Devise ..After first login should ask for change password

妖精的绣舞 提交于 2019-12-05 02:10:37
问题 I am using devise as authentication in my application. I need to implement feature in devise. After first login user should ask to change password. I tried through model after_create :update_pass_change def update_pass_change self.pass_change = true self.save end 回答1: Checking current_user.sign_in_count is way to judge first login. You'll do something like this. class ApplicationController < ActionController::Base def after_sign_in_path_for(resource) if current_user.sign_in_count == 1 edit