ruby-on-rails-3

Get title, content via link in rails

点点圈 提交于 2020-01-10 09:03:59
问题 I just started learning rails. Could you help me understand parsing a single link? Good tutorial will help too... The question: When you submit a link in Digg, Facebook etc.. After you say attach link it parses the link to fetch the title, content, images of a particular url. Could you please help me how a similar thing can be implemented in rails? I have looked at feed parsers like feedzirra etc but they seem to get the complete website feed.. Not just the link we are looking for.. Or is it

How can I configure Devise for Ruby on Rails to store the emails and passwords somewhere other than in the user model?

ε祈祈猫儿з 提交于 2020-01-10 09:01:37
问题 I'd like to store emails in a separate table and allow users to save multiple emails and log in with any of them. I'd also like to store passwords in a different table. How can I configure Devise to store authentication info elsewhere? Worst case scenario, if I just have to hack into it, is there a generator to just port everything over to the app? I noticed there was a generator for the views. Thanks. 回答1: To do this, you have just to set up your models properly, create your email

Argument Error: The scope body needs to be callable

点点圈 提交于 2020-01-10 07:19:13
问题 I'm working through the 'Ruby On Rails 3 Essential Training' and have received a problem when using name scopes. When finding records and using queries withing the Rails console everything went smoothly until I tried to use a name scope in my subject.rb file. This is my code in the subject.rb file. Class Subject < ActiveRecord::Base scope :visible, where(:visible => true) end I saved the .rb file and restarted my Rails console but when I run from my rails console: subjects = Subject.visible I

Strange I18n date output with rails

人走茶凉 提交于 2020-01-10 04:55:10
问题 I've got a strange problem with date translations in my Ruby On Rails 3 application, and I really don't understand why... Here are my en.yml and fr.yml : fr: date: formats: default: "%d/%m/%Y" short: "%e %b" long: "%e %B %Y" time: formats: default: "%d %B %Y %H:%M:%S" short: "%d %b %H:%M" long: "%A %d %B %Y %H:%M" am: 'am' pm: 'pm' en: date: formats: default: "%Y-%m-%d" long: "%B %d, %Y" short: "%b %d" time: am: am formats: default: ! '%a, %d %b %Y %H:%M:%S %z' long: ! '%B %d, %Y %H:%M' short

Can't create new user with ActiveAdmin

↘锁芯ラ 提交于 2020-01-10 04:39:06
问题 I just added active admin to my rails app and I'm unable to create a new user. I am using the user model that active admin creates with a few added columns like first and last name. When I fill out the form for a new user and click create new user, that page refreshes but doesn't save my user and doesn't go to the recap page with the successful message. here is my AdminUser model class AdminUser < ActiveRecord::Base devise :database_authenticatable, :recoverable, :rememberable, :trackable,

DateTime arithmetic in an ActiveRecord query (PostgreSQL)

时间秒杀一切 提交于 2020-01-10 04:08:15
问题 I have two datetime columns in a User / users table: created_at and birthdate . I'd like to find users whose birthdate is less than 13 years before their creation date. The equivalent Rails if statement would be ((created_at - birthdate) < 13.years) How do I translate this to an ActiveRecord query (one that'll work on PostgreSQL)? Is this even possible, or will I have to iterate over all records manually? 回答1: The easiest way to do this is to use an interval, then it is pretty much a straight

Jquery Rails 3… form submits twice… deletes twice… help

无人久伴 提交于 2020-01-10 03:15:12
问题 It seems like eveyone has this problem but no one has a laymans terms answer or even a proper solutions. I have a form that uses ajax to submit the form and automatically adds it to the list below the text field. The form submits twice so i have two identical (apart form the ID) records. Worse still is when you try to delete it wont renew the page because its tried to delete the same record twice. I hope someone has a great answer out there... btw im new to rails. code: index.html.erb <h1

Ruby on Rails MYSQL error Access denied for user 'root@localhost'

江枫思渺然 提交于 2020-01-09 19:47:48
问题 I get the following error when starting rails server with a new app: /Users/fred/.rvm/gems/ruby-1.9.2-p180/gems/mysql2-0.2.6/lib/mysql2/client.rb:37:in `connect': Access denied for user 'root'@'localhost' (using password: YES) (Mysql2::Error) Here is my database.yml # MySQL. Versions 4.1 and 5.0 are recommended. # # Install the MySQL driver: # gem install mysql2 # # And be sure to use new-style password hashing: # http://dev.mysql.com/doc/refman/5.0/en/old-client.html development: adapter:

Gems/Services for autoscaling Heroku's dynos and workers

我的梦境 提交于 2020-01-09 12:51:16
问题 I want to know if there are any good solutions for autoscaling dynos AND workers on Heroku in a production environment (probably a different solution for each of those, as they are pretty unrelated). What are you/companies using, regarding this? I found lots of options, but none of them seem really mature for a production environment. There is Heroscale, which seem to introduce some latency as it does not run locally, and I also heard of some downtime. There are modifications of delayed_jobs,

WEBrick: RequestURITooLarge: should I update or use a different server?

风流意气都作罢 提交于 2020-01-09 11:11:46
问题 I currently have: $ rails s => Booting WEBrick => Rails 3.0.9 application starting in development on http://0.0.0.0:3000 => Call with -d to detach => Ctrl-C to shutdown server [2011-11-30 13:18:00] INFO WEBrick 1.3.1 [2011-11-30 13:18:00] INFO ruby 1.9.2 (2011-02-18) [x86_64-darwin10.8.0] [2011-11-30 13:18:00] INFO WEBrick::HTTPServer#start: pid=4204 port=3000 The problem I'm having is I'm using openID for auth and getting the following error: [2011-11-30 13:18:19] ERROR WEBrick::HTTPStatus: