ruby-on-rails-3

Getting rails3-autocomplete-jquery gem to work nicely with Simple_Form with multiple inputs

孤人 提交于 2019-12-25 03:38:16
问题 So I am trying to implement multiple autocomplete using this gem and simple_form and am getting an error. I tried this: <%= f.input_field :neighborhood_id, collection: Neighborhood.order(:name), :url => autocomplete_neighborhood_name_searches_path, :as => :autocomplete, 'data-delimiter' => ',', :multiple => true, :class => "span8" %> This is the error I get: undefined method `to_i' for ["Alley Park, Madison"]:Array In my params, it is sending this in neighborhood_id : "search"=>{"neighborhood

Errors while using paperclip in rails app

做~自己de王妃 提交于 2019-12-25 03:37:11
问题 At the moment I try to replace attachment_fu fileuploading plugin with paperclip. But there are some errors while uploading: My controller looks like this: def create add_breadcrumb 'breadcrumb.upload_file', {:action => :new} puts "BLUBBBBBBBBBBBBBBBBBBBBBBBBBBB" puts params[:upload] @upload = Upload.create(params[:upload]) @upload.lecturer_id = current_user.id if @upload.save flash[:notice] = I18n.t("flash.saved") redirect_to :action => :index else render :action => :new end end and my model

Fetch value from Redmine Custom Custom field

微笑、不失礼 提交于 2019-12-25 03:36:27
问题 I have created custom field in redmine wher we type the client phone number manually.Also written a ruby code in redmine custom workflow to send sms to client when ticket id is raised.In the code I can type phone number but i actually want to fetch that phone number which we type before creating the new issue..So how do i fetch the value of phone number from the custom field and link it to the code? Please suggest me 回答1: IssueCustomField.where("field = 8 AND value like '+31%'") Replace the

Wrong number of Arguments ( 3 for 2 ) in Rails in f.select

爱⌒轻易说出口 提交于 2019-12-25 03:36:12
问题 I have this multiple select list which gives me an error Wrong number of Arguments ( 3 for 2 ) in a form_form a "Topic" model which has_many :curriculums, :through => another_model <%= f.select :curriculum_ids, options_from_collection_for_select(Curriculum.all, :id, :name, @topic.curriculum_ids), {}, { "data-placeholder"=>"Select Curriculum", :multiple=>true , :class=>"chzn-select"} %> However this code works just fine in another controller's view : Here we have a Question model with has_and

Rails Nested Attributes Mass Assignment Error

a 夏天 提交于 2019-12-25 03:34:49
问题 I have a user model where I cannot create a client due to it being unwritable in mass assignment. How do I make it so that I can create a client model? Code and error are found here: http://pastie.org/1206482 回答1: I think you have to add: attr_accessible :client_attributes to your user model. client_attributes is the hash in the user hash posted to the create action. The transmitted hash looks something like this: :user => { :username => "one", ..., :client_attributes => { :name => "client" }

rails 3 rake routes not working, no routes shown as output

若如初见. 提交于 2019-12-25 03:28:24
问题 When I execute bundle exec rake routes --trace the output is: NOTE: Gem.source_index is deprecated, use Specification. It will be removed on or after 2011-11-01. Gem.source_index called from /usr/local/rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.0.10/lib/bundler/shared_helpers.rb:3. NOTE: Gem.source_index is deprecated, use Specification. It will be removed on or after 2011-11-01. Gem.source_index called from /usr/local/rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.0.10/lib/bundler/source

Rescuing from Twitter Gem

拜拜、爱过 提交于 2019-12-25 03:24:56
问题 I have a tweets_controller #called when user submits twitter form def message unless current_user session[:twitter_message] = params[:twitter_message] #sets the message from the form so it's available for send_tweet in tweet.rb after we pass through omniauth redirect_to '/auth/twitter' #redirects to authorize via omniauth/twitter and create the user else @auth = Authorization.find_by_user_id(current_user) Tweet.update_status(@auth, params[:twitter_message]) redirect_to edit_user_path(current

Rspec checking for json response

杀马特。学长 韩版系。学妹 提交于 2019-12-25 03:24:38
问题 I am trying to create a mock object and i am checking whether my method receives the right param and expected result. Below is my spec . require 'spec_helper' describe User do let(:username) {"test@test.com"} let(:password) {"123"} let(:code) {"0"} context "when signing in" do it "should sign in" do user = double("user") expected_results = { "token": "123" } allow(user).to receive(:login).with({email: username, password: password, code: code}) .and_return(expected_results) expect(user.login)

Prawn + Prawnto Issue

做~自己de王妃 提交于 2019-12-25 03:23:06
问题 I know prawn is working because I have a show action that if I add .pdf on to the end of it loads show.pdf.prawn. However, I have a form: <%= form_tag(:controller => "/holders", :action=> "generate", format: "pdf") do %> <%= label_tag(:count, "How Many Students?") %> <%= text_field_tag(:count) %> <%= hidden_field_tag :holder_id, value: @holder%> <%= submit_tag("Generate Course Lesson") %> <% end %> That submits count to the the generate action. Inside my generate action I have the following:

How do I restore three items from a backup made using Heroku PG Backups?

风流意气都作罢 提交于 2019-12-25 03:16:14
问题 I've got a Rails app running on Heroku and installed the free pgbackups addon. There's three records I'd like to restore from the backup. According to Heroku docs when you do a restore, it restores the whole database. How do I restore just these three records? 回答1: Create a new database, load the pgbackup into it, and then cherry pick what you want out of it. 回答2: As far as I know Heroku is using what's referred to as the "-Fc" format for everything, which is described in the pg_dump section