ruby-on-rails-3.2

Rake db:test:prepare task deleting data in development database

六眼飞鱼酱① 提交于 2019-12-03 17:52:17
问题 Using a simple Rails sqlite3 configuration example in my config/database.yml for a Rails 3.2.6 app, I used to reset my development database, re-seed it, and prepare my test database simply by performing: $ rake db:reset $ rake db:test:prepare After looking at this blog entry about testing a Rails application with Travis CI on different database engines, I thought I'd give it a try, so I installed mysql and postgresql using Homebrew (I'm on OSX Snow Leopard), set them up as per the brew info

Google plus insert activity on stream

对着背影说爱祢 提交于 2019-12-03 17:09:18
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, plus.login, plus.me, plus.media.upload, plus.profiles.read, plus.stream.read, plus.stream.write, plus

Rails has_many through query depending on the through table attribute

六月ゝ 毕业季﹏ 提交于 2019-12-03 16:57:47
问题 Having some problems with a has_many through query. Using the example here: http://guides.rubyonrails.org/association_basics.html#the-has_many-through-association class Physician < ActiveRecord::Base has_many :appointments has_many :patients, :through => :appointments end class Appointment < ActiveRecord::Base belongs_to :physician belongs_to :patient end class Patient < ActiveRecord::Base has_many :appointments has_many :physicians, :through => :appointments end The Appointment table has a

ActiveAdmin with CanCanAdapter causing infinite redirect on dashboard

試著忘記壹切 提交于 2019-12-03 14:29:56
When using the CanCan adapter in ActiveAdmin 0.6.0. I have a resource working and authorization is working. However, when I go to /admin , the root ActiveAdmin page, it redirects to /admin and continues this forever. If the user does not have access to a page, ActiveAdmin redirects to the Dashboard. If the user doesn't have access to the dashboard, this results in an infinite redirect. Solution is to give the user the ability to read the dashboard page. Place this in the ability model object: can :read, ActiveAdmin::Page, :name => "Dashboard" This is mentioned in the authorization adapter

Factory already registered: user (FactoryGirl::DuplicateDefinitionError)

吃可爱长大的小学妹 提交于 2019-12-03 14:23:17
问题 Description of problem: - I've setup factory_girl_rails however whenever I try and load a factory it's trying to load it multiple times. Environment: - rails (3.2.1) - factory_girl (2.5.2) - factory_girl_rails (1.6.0) - ruby-1.9.3-p0 [ x86_64 ] > rake spec --trace ** Execute environment -- Creating User Factory -- Creating User Factory rake aborted! Factory already registered: user The only other thing I've changed is: /config/initializers/generator.rb Rails.application.config.generators do

Asciifolding not working Elastic Search Rails

霸气de小男生 提交于 2019-12-03 14:20:16
I am having a really bad time trying to get " asciifolding " working for my Rails app. I want to search words containing " accented " characters for example i want " foróige " to come up when i search " foroige ". I have tried many things. A couple of them are below. analysis: { analyzer: { text: { tokenizer: "standard", filter: ["standard","lowercase", "asciifolding"], char_filter: 'html_strip' }, sortable: { tokenizer: "keyword", filter: ["lowercase", "asciifolding"], char_filter: 'html_strip' } } } I have also tried char_filter by following James Healey charmap for sphinx for accented

Dynamic CSS in Rails asset pipeline, compile on fly

你说的曾经没有我的故事 提交于 2019-12-03 13:58:40
问题 I'm building a site in Rails 3.2. Its been 3 years since I've touched Rails or Ruby, so I'm rusty on both, plus the last time I used rails is was Rails 2.3. Needless to say, please excuse any "simple" questions below. Here are the specs Multi Tennant CMS/Store Site http://company1.mywebsite.com http://company2.mywebsite.com etc. Each "Store" (aka sub-domain) can have its own look, feel, etc. through CSS customizations The customizations can be performed in a UI within the app allowing the

first_or_create by email and then save the nested model

[亡魂溺海] 提交于 2019-12-03 13:08:47
I two models User and Submission as follows: class User < ActiveRecord::Base # Associations has_many :submissions accepts_nested_attributes_for :submissions # Setup accessible (or protected) attributes for your model attr_accessible :email, :name, :role, :submission_ids, :quotation_ids, :submissions_attributes validates :email, :presence => {:message => "Please enter a valid email address" } validates :email, :uniqueness => { :case_sensitive => false } end class Submission < ActiveRecord::Base belongs_to :user attr_accessible :due_date, :text, :title, :word_count, :work_type, :rush, :user,

How to access params in the callback of a Rails model?

匆匆过客 提交于 2019-12-03 12:41:07
I have a callback of a model that needs to create a dependent object based on another field entered in the form. But params is undefined in the callback method. Is there another way to access it? What's the proper way to pass a callback method parameters from a form? class User < ActiveRecord::Base attr_accessible :name has_many :enrollments after_create :create_enrollment_log private def create_enrollment_log enrollments.create!(status: 'signed up', started: params[:sign_up_date]) end end params are not accessible in models, even if you pass them as a parameter then it would be consider as

Rails has_many through query depending on the through table attribute

左心房为你撑大大i 提交于 2019-12-03 11:55:20
Having some problems with a has_many through query. Using the example here: http://guides.rubyonrails.org/association_basics.html#the-has_many-through-association class Physician < ActiveRecord::Base has_many :appointments has_many :patients, :through => :appointments end class Appointment < ActiveRecord::Base belongs_to :physician belongs_to :patient end class Patient < ActiveRecord::Base has_many :appointments has_many :physicians, :through => :appointments end The Appointment table has a column named appointment_date How would I get all the Patients from a Specific Physician that have an