ruby-on-rails-3

Redirect to edit path using drop down and Jquery in rails

久未见 提交于 2020-01-02 23:12:44
问题 I have a select drop down of items. When the user selects and item I need to redirect to edit_item_path for the item_id. e.g. If user selects and item with id =5 I need to redirect to items/5/edit path How to do this in rails 3 and jquery? 回答1: Lets say that your dropdown looks like this: <select id="editable_pages"> <option value="1">Edit 1</option> <option value="2">Edit 2</option> </select> in that case following jquery snippet should works: $('#editable_pages').change(function() { window

UserMailer with Devise

拈花ヽ惹草 提交于 2020-01-02 23:09:34
问题 am using my custom mailer UserMailer to send emails. It works perfect in development, but in production i get error 500, that is when am trying to retrieve my password on forgetting. here is what is in the production logs in the production mode Processing by Devise::PasswordsController#create as HTML Parameters: {"utf8"=>"✓","authenticity_token"=>"xxxxxxxxxxxxxxx", "user"=>{"email"=>"sam@gmail.com"}, "commit"=>"Send me r$ Completed 500 Internal Server Error in 2ms NameError (uninitialized

Rails 3 uniqueness validation with scope on polymorphic table

泪湿孤枕 提交于 2020-01-02 23:05:23
问题 I've got the following setup: class Vote < ActiveRecord::Base belongs_to :voteable, :polymorphic => :true, :counter_cache => true end class Proposition < ActiveRecord::Base has_many :votes, :as => :voteable end class Winner < ActiveRecord::Base has_many :votes, :as => :voteable end The Vote table looks like this: t.string "ip_address" t.integer "voteable_id" t.string "voteable_type" I want to validate the following. A user with a given ip_address can only vote on 1 proposition. So the

ROR + MVC Disable Browser Cache

百般思念 提交于 2020-01-02 21:19:05
问题 I am looking for method to disable Browser Cache for entire Ruby On Rails MVC Website I found following method, Response.Cache.SetExpires(DateTime.Now.AddSeconds(5)); Response.Cache.SetCacheability(HttpCacheability.Public); Response.Cache.SetValidUntilExpires(true); and also for meta tag method. <meta http-equiv="PRAGMA" content="NO-CACHE"> But i am looking for simple method, to disable browser cache for entire website. 回答1: Friends, After a long search on Google. I got one solution for this.

Rails attributes headache

爱⌒轻易说出口 提交于 2020-01-02 20:10:21
问题 newbie rails question coming up. I have a class like this: class Thing < ActiveRecord::Base attr_accessible :name attr_accessor :name validates_uniqueness_of :name, :case_sensitive => false end I have done a migration and the table looks okay. I then fire up the rails console and try the following: t = Thing.new(:name => "test") => #<Thing id: nil, name: nil, description: nil, created_at: nil, updated_at: nil> already here it says name is nil, why? Continuing on, I try this: t.name => "test"

Rails 3.1 app can't install sqlite3 gem because libraries are out of date

雨燕双飞 提交于 2020-01-02 20:03:36
问题 The latest SQLite3 library available on CentOS 5.6 and which is installed is version 3.3.6. It's my understanding that the sqlite3 gem needs version 3.6 or higher. How do I get my app to work with SQLite3 without upgrading the library on my server? It's in a work environment and I'm simply not allowed to upgrade it. 回答1: You could compile a static library of the version of sqlite you require. Then install the sqlite3 gem with a reference to your new static library. While I haven't tested this

Rails 3.1 app can't install sqlite3 gem because libraries are out of date

旧街凉风 提交于 2020-01-02 20:00:54
问题 The latest SQLite3 library available on CentOS 5.6 and which is installed is version 3.3.6. It's my understanding that the sqlite3 gem needs version 3.6 or higher. How do I get my app to work with SQLite3 without upgrading the library on my server? It's in a work environment and I'm simply not allowed to upgrade it. 回答1: You could compile a static library of the version of sqlite you require. Then install the sqlite3 gem with a reference to your new static library. While I haven't tested this

Issue with Paperclip/S3 in Rails 3.2.5 “cannot load such file — aws-sdk”

家住魔仙堡 提交于 2020-01-02 19:29:06
问题 Image Uploading was working fine, but when I tried switching it to S3, it started throwing an error. I get the following error when I try to create a new image upload: cannot load such file -- aws-sdk (You may need to install the aws-sdk gem) Relevant gems: gem 'rails', '3.2.5' gem 'paperclip' gem 'aws-sdk' config/s3.yml: development: bucket: bucketname access_key_id: # secret_access_key: # test: bucket: bucketname access_key_id: # secret_access_key: # image_upload.rb: has_attached_file

cap deploy:setup hangs?

蹲街弑〆低调 提交于 2020-01-02 19:21:08
问题 Im having setup a empty git repo bare on the server side and everything setup. Cap deploy:setup does this [109.etc] env RAILS_ENV=production sh -c 'git clone git@109.etc:srv/paintings.git /srv/paintings/current' ** [out :: 109.etc] Initialized empty Git repository in /srv/paintings/current/.git/ ** [out :: 109.etc] The authenticity of host '109.etc (109.etc)' can't be established. ** [out :: 109.etc] RSA key fingerprint is e9:af:d6:d3:0e:f5:de:a3:4a:31:6e:8e:4a:c7:b7:ee. ** [out :: 109.etc]

Unable to start SOLR server (Ruby on Rails)

非 Y 不嫁゛ 提交于 2020-01-02 19:15:54
问题 I'm using sunspot_rails and sunspot gems in my Rails3 application and following the steps to installing sunspot on https://github.com/outoftime/sunspot, I cannot get my sunspot server to run. When I enter my directory, run bundler and then run rake sunspot:solr:start I get the following error Emil@Emil-PC /cygdrive/c/work/pilarhq $ rake sunspot:solr:start (in /cygdrive/c/work/pilarhq) DEPRECATION WARNING: You are using the old router DSL which will be removed in R ails 3.1. Please check how