ruby-on-rails-3

Display link in Rails form error message

前提是你 提交于 2020-02-18 05:07:12
问题 On our sign-up form, we validates_uniqueness_of :email When the a user is attempting to use our sign up form and they specify an existing email address, I'd like them to see an error message like this This email address is already in use. If you're having trouble logging in, you can reset your password Obviously, I'd like to use the named route for the link, but my User model does not have access to it. How can I accomplish this? Side note: We will be offering translations for our app soon

ERROR - Guard::RailsAssets failed to achieve its <start>, exception was (Rails 4/ zeus/guard)

青春壹個敷衍的年華 提交于 2020-02-07 17:14:02
问题 I am getting this error whenever I load Guard and I think it fails to precompile locally my assets due to this. When I load guard with $ guard I get: 16:55:35 - ERROR - Guard::RailsAssets failed to achieve its <start>, exception was: > [#6D5274147654] TypeError: can't modify immutable index > [#6D5274147654] /home/mathieu/.rvm/gems/ruby-2.0.0-p451@rails3tutorial2ndEd/gems/sprockets-2.12.3/lib/sprockets/index.rb:81:in `expire_index!' > [#6D5274147654] /home/mathieu/.rvm/gems/ruby-2.0.0-p451

trouble building with factory girl

我怕爱的太早我们不能终老 提交于 2020-02-07 05:28:22
问题 so the issue is that mail is not being added to ActionMailer::Base.deliveries. FactoryGirl.create is returning nil. what am I doing wrong? FactoryGirl.define do factory :provisional_user do sequence(:email) { |n| "bangbang_#{n}@example.com" } first_name "Provisional" last_name "User" partner "source2" unsubscribed false end factory(:unsubscribed_user, :parent => :provisional_user, :class => ProvisionalUser) do sequence(:email) { |n| "do_not_contact@example.com" } first_name "Unsubscribed"

Rails - continuing to work on check_box_tag

丶灬走出姿态 提交于 2020-02-06 08:48:26
问题 Continuing my project on themoviedb api, here is now what I have. I added a method to pass the attributes of the query. My method is: def tmdb_search params.require(:tmdb_ids).permit(:id, :title, :release_date) end I pass this to: def create_from_tmdb(tmdb_search) tmdb_search = params[:tmdb_ids] @movie = Tmdb::Movie.find(tmdb_search) end I proceed then in adding the movie to my db: def add_tmdb(create_from_tmdb) create_from_tmdb = (params[:tmdb_ids]) @movie = Movie.new(create_from_tmdb)

Rails help ActionView::Template::Error HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts

随声附和 提交于 2020-02-06 07:57:10
问题 My rails app runs fine on my locale machine with mysql. But on Heroku I get the following error: http://pastie.org/1697772 My kategoris_helper: module KategorisHelper def sortkat(column, title = nil) title ||= column.titleize css_class = column == sort_column ? "current #{sort_direction}" : nil direction = column == sort_column && sort_direction == "asc" ? "desc" : "asc" link_to title, {:sort => column, :direction => direction}, {:class => css_class} end end My Kategoris controller: class

show data from table on Ruby

与世无争的帅哥 提交于 2020-02-06 06:16:09
问题 I am new on Ruby and I am trying get data from table. so when read this <%= puts @note.inspect %> I have this this result. [#<Note id: 1, user_id: 1, note_type: 0, text: "Barev dzez", lat: 40.2290542420142, lng: 44.420879046875, deleted: false, created_at: "2012-04-26 14:10:05", updated_at: "2012-04-26 14:10:05">] So when I call Note.text (for instance) I got nil result. So what should I write here to get data from array? Thanks 回答1: @note is an Array with one Note object. You need to get the

show data from table on Ruby

房东的猫 提交于 2020-02-06 06:15:08
问题 I am new on Ruby and I am trying get data from table. so when read this <%= puts @note.inspect %> I have this this result. [#<Note id: 1, user_id: 1, note_type: 0, text: "Barev dzez", lat: 40.2290542420142, lng: 44.420879046875, deleted: false, created_at: "2012-04-26 14:10:05", updated_at: "2012-04-26 14:10:05">] So when I call Note.text (for instance) I got nil result. So what should I write here to get data from array? Thanks 回答1: @note is an Array with one Note object. You need to get the

show data from table on Ruby

让人想犯罪 __ 提交于 2020-02-06 06:15:06
问题 I am new on Ruby and I am trying get data from table. so when read this <%= puts @note.inspect %> I have this this result. [#<Note id: 1, user_id: 1, note_type: 0, text: "Barev dzez", lat: 40.2290542420142, lng: 44.420879046875, deleted: false, created_at: "2012-04-26 14:10:05", updated_at: "2012-04-26 14:10:05">] So when I call Note.text (for instance) I got nil result. So what should I write here to get data from array? Thanks 回答1: @note is an Array with one Note object. You need to get the

Rails 3 and Controller Instance Variables Inside a Helper

六眼飞鱼酱① 提交于 2020-02-05 07:37:53
问题 I just encounter a problem similar to http://www.ruby-forum.com/topic/216433 I need to access controller instance variable from helper. Here is the code I have done, and it's not work. Controller: class ApplicationController < ActionController::Base helper_method :set_background_type #for action only background setting #for controller-wise background setting def set_background_type(string) @background_type = string end end Helper: module ApplicationHelper def background_type @background_type

Why is this button_to rendering incorrectly in Rails 3.2.11?

二次信任 提交于 2020-02-05 05:54:21
问题 I am working in Rails 3.2.11 and I cannot figure out why this button will not render per the API documentation. Specifically, I cannot get the data-remote attribute to render correctly. Is there a bug in my code? Right now this code: <%= button_to "Test", :action => "test", :remote => true, :form_class => "test_button" %> yields this HTML: <form action="/cloud_status/test?form_class=test_button&remote=true" class="button_to" method="post"> Per the API specs it should render this: <form action