ruby-on-rails-3

Rails 3 ActiveRecord chaining

﹥>﹥吖頭↗ 提交于 2020-01-01 11:57:35
问题 I'm new to Rails and I'm not sure why my chaining isn't working. Working my_model.select('name').where('status_id = 6').all Not Working my_model.select('name').where('status_id = 6').order('name') Why does chaining the order after the where not execute the query? I've tried adding the .all after the .order but that didn't seem to work either. 回答1: Looks like this is a known bug in the jdbc adapter: http://kenai.com/jira/browse/ACTIVERECORD_JDBC-154 If you make these changes it will fix it:

Rails proxy controller not pulling images through properly, how to modify appropriately?

爷,独闯天下 提交于 2020-01-01 11:40:56
问题 I'm having to implement a proxy on a Rails 3.1 app to overcome some cross-domain JS issues. So far I have it retrieving web page text source seemingly right, however it commonly misses images (perhaps relative paths?) in the page and then when I direct it with an absolute path to an image it will show the ascii encoding of the image rather than the image itself, I think for obvious reasons from the code for someone familiar with the topic. I was hopeful that someone would be able to revise

Rails proxy controller not pulling images through properly, how to modify appropriately?

与世无争的帅哥 提交于 2020-01-01 11:40:07
问题 I'm having to implement a proxy on a Rails 3.1 app to overcome some cross-domain JS issues. So far I have it retrieving web page text source seemingly right, however it commonly misses images (perhaps relative paths?) in the page and then when I direct it with an absolute path to an image it will show the ascii encoding of the image rather than the image itself, I think for obvious reasons from the code for someone familiar with the topic. I was hopeful that someone would be able to revise

How can Ruby on Rails's “content_for :title” get something that is assigned later?

爷,独闯天下 提交于 2020-01-01 11:39:11
问题 The short question is: how can a subpage's <% content_for :title do 'Showing product' end %> set the :title for the main layout? details: We can use in the application layout application.html.erb <title><%= content_for :title %> ... <%= yield %> and I think yield returns the content for a subpage, such as from show.html.erb , where it contains: <% content_for :title do 'Showing product' end %> How can the :title somehow get used by something above the yield ? I thought the title part is

Rails Devise, how to skip the confirmation email but still generate a confirmation token?

余生长醉 提交于 2020-01-01 11:04:08
问题 I'm using user.skip_confirmation! To skip the devise email confirmation when a new user is added by an existing user. The problem with the skip_confirmation is that it does not generate a confirmation token. I want to manually send a confirmation email which means I need a confirmation token. How can I skip the devise confirmation email yet still generate a confirmaton_token to allow me to manually send a custom confirmation email to added users? Thanks 回答1: See confirmable.rb. In particular,

Rails Devise, how to skip the confirmation email but still generate a confirmation token?

旧街凉风 提交于 2020-01-01 11:03:53
问题 I'm using user.skip_confirmation! To skip the devise email confirmation when a new user is added by an existing user. The problem with the skip_confirmation is that it does not generate a confirmation token. I want to manually send a confirmation email which means I need a confirmation token. How can I skip the devise confirmation email yet still generate a confirmaton_token to allow me to manually send a custom confirmation email to added users? Thanks 回答1: See confirmable.rb. In particular,

Rails Devise, how to skip the confirmation email but still generate a confirmation token?

丶灬走出姿态 提交于 2020-01-01 11:02:02
问题 I'm using user.skip_confirmation! To skip the devise email confirmation when a new user is added by an existing user. The problem with the skip_confirmation is that it does not generate a confirmation token. I want to manually send a confirmation email which means I need a confirmation token. How can I skip the devise confirmation email yet still generate a confirmaton_token to allow me to manually send a custom confirmation email to added users? Thanks 回答1: See confirmable.rb. In particular,

Paperclip - delete a file from Amazon S3?

最后都变了- 提交于 2020-01-01 10:58:12
问题 I need to be able to delete files from S3 that are stored by users, such as profile photos. Just calling @user.logo.destroy doesn't seem to do the trick - I get [paperclip] Saving attachments. in the logs and the file stays right there in the S3 bucket. How can the file itself be removed? 回答1: This are the methods from Paperclip that can be used to remove the attachments: # Clears out the attachment. Has the same effect as previously assigning # nil to the attachment. Does NOT save. If you

Unable to run growl notifications and gem growl_notify throws errors

Deadly 提交于 2020-01-01 10:49:33
问题 I am unable to get growl notifications when i run $guard Do i need any particular version for growl_notify? Growl version = 1.2 Here is my gem file. gem 'rails', '3.1.3' gem 'sqlite3' group :development, :test do gem 'rspec-rails' gem 'capybara', :git => 'git://github.com/jnicklas/capybara.git' gem 'launchy' gem 'database_cleaner' gem 'rb-fsevent', :require => false if RUBY_PLATFORM =~ /darwin/i gem 'guard-rspec' gem 'guard-livereload' end gem 'growl' group :test do gem 'guard-spork' end

Question about ActiveRecord#default_scope method and default ordering

↘锁芯ラ 提交于 2020-01-01 10:28:49
问题 Question about default_scope with Rails 2/3. On my Rails 3 project, I'm using a lot default_scope to order by created_at desc. So first I wrote : default_scope order("created_at desc") in many of my models. But the problem is that created_at exist in almost every of my application tables... So if I write a query that simply makes a join on two tables, I get a SQL error ambiguous column created_at... So I had to rewrite all default_scopes to include the table_name, like: default_scope order(