ruby-on-rails-3

Delayed_job Won't Run User defined method

折月煮酒 提交于 2019-12-22 16:41:04
问题 I have been trying to get DelayedJob to run some user defined methods in the background. For this test case I defined the following method in a helper: def test_case u = User.new u.first_name = "JimBob" u.last_name = "joe" u.email = "itworked@eureka.com" u.password = "sailsJ123" u.password_confirmation = "sailsJ123" u.save end Then, in a controller action, I define: def action_name #whatever it does outside of this test_case end This causes test_case to create a new user when the action here

Form_for inputs and submit button in different partials

喜你入骨 提交于 2019-12-22 14:03:48
问题 Is there a way to split an a form (using form_for) across two partials? I want to have text boxes in one partial, and my submit button in another. 回答1: You can do that as follows: # _post_form.html.erb <%= form_for(@post) do |f| %> <% @form = f%> <%= render 'form_fields'%> <%= render 'form_actions'%> <% end %> # _form_fields.html.erb <div class="field"> <%= @form.label :name %><br /> <%= @form.text_field :name %> </div> <div class="field"> <%= @form.label :title %><br /> <%= @form.text_field

RailsTutorial 3.2 Ch 11 - PostgreSQL syntax error breaks the status feed

拟墨画扇 提交于 2019-12-22 14:03:38
问题 I'm in Section 11.3.1 of the Rails Tutorial, and all tests were passing prior to this. Afterward, the home page (which has the micropost feed) breaks with this error: PG::Error: ERROR: invalid input syntax for integer: "98, 1" LINE 1: ...CT COUNT(*) FROM "microposts" WHERE (user_id IN ('98, 1') O... ^ : SELECT COUNT(*) FROM "microposts" WHERE (user_id IN ('98, 1') OR user_id = 101) And several of the tests fail with a similar issue. Here's the first one: 1) Authentication authorization as

How can I use ActiveRecord on a database that has a column named 'attribute'? (DangerousAttributeError)

你。 提交于 2019-12-22 14:02:23
问题 I am accessing a database that I can't change and it has a column named attribute defined. Anytime I try to access an attribute , I get this exception: attribute? is defined by ActiveRecord(ActiveRecord::DangerousAttributeError) my code: class User < ActiveRecord::Base def self.authenticate(username,password) where(:username => username, :value => password).first end end I found a plan on the ruby on rails mailing list for fix the problem but not work for me class << self def instance_method

Bundler isn't loading gems

眉间皱痕 提交于 2019-12-22 12:32:41
问题 I have been having a problem with using Bundler and being able to access my gems without having to require them somewhere, as config.gem used to do that for me (as far as I know). In my Rails 3 app, I defined my Gemfile like so: clear_sources source "http://gemcutter.org" source "http://gems.github.com" bundle_path "vendor/bundler_gems" ## Bundle edge rails: git "git://github.com/rails/arel.git" git "git://github.com/rails/rack.git" gem "rails", :git => "git://github.com/rails/rails.git" ##

Bundler isn't loading gems

送分小仙女□ 提交于 2019-12-22 12:32:13
问题 I have been having a problem with using Bundler and being able to access my gems without having to require them somewhere, as config.gem used to do that for me (as far as I know). In my Rails 3 app, I defined my Gemfile like so: clear_sources source "http://gemcutter.org" source "http://gems.github.com" bundle_path "vendor/bundler_gems" ## Bundle edge rails: git "git://github.com/rails/arel.git" git "git://github.com/rails/rack.git" gem "rails", :git => "git://github.com/rails/rails.git" ##

Devise & Custom Rails User URLs

纵然是瞬间 提交于 2019-12-22 12:26:10
问题 I am currently using Rails 3.2.5 with the latest devise gem. Currently users can access their profile page at... example.com/users/john-doe I want to remove the users portion of the url, so the url would be example.com/john-doe . Is this possible with devise? Right now in my routes file I have the following... devise_for :users, :controllers => {:omniauth_callbacks => 'omniauth_callbacks'} 回答1: Just add a route for it. You will probably want it to be the last one in the routes file. Something

Rails App on Heroku Sending Email Error

末鹿安然 提交于 2019-12-22 12:20:25
问题 I have my own domain name hosted on Google Apps. My email sending works in development mode on my laptop. In production on Heroku (cedar stack) I get this error: Net::SMTPAuthenticationError (535-5.7.8 Username and Password not accepted. Learn more at app/controllers/applicants_controller.rb:16:in `create'): Here is my production.rb file: config.action_mailer.default_url_options = { :host => 'mydomain.com' } # ActionMailer Config # Setup for production - deliveries, no errors raised config

Rails App on Heroku Sending Email Error

断了今生、忘了曾经 提交于 2019-12-22 12:20:15
问题 I have my own domain name hosted on Google Apps. My email sending works in development mode on my laptop. In production on Heroku (cedar stack) I get this error: Net::SMTPAuthenticationError (535-5.7.8 Username and Password not accepted. Learn more at app/controllers/applicants_controller.rb:16:in `create'): Here is my production.rb file: config.action_mailer.default_url_options = { :host => 'mydomain.com' } # ActionMailer Config # Setup for production - deliveries, no errors raised config

Facing error installing mysql2 gem

我们两清 提交于 2019-12-22 12:19:53
问题 Rails ask me to succeed with gem install mysql2 and on trying I got the following error.So what is mostly problem with such error? Detail of error is below: Could not create Makefile due to some reason, probably lack of necessary libraries and/or headers. Check the mkmf.log file for more details. You may need configuration options. Provided configuration options: --with-opt-dir --without-opt-dir --with-opt-include --without-opt-include=${opt-dir}/include --with-opt-lib --without-opt-lib=${opt