ruby-on-rails-3

Help Setting up Ruby on Rails and MySQL - Reward Offered

不打扰是莪最后的温柔 提交于 2020-01-13 10:44:06
问题 I am desperately in need of help from any charitable ruby/rails experts out there. I really want to learn RoR, but I can't get anywhere because every time I get to the stage where I need to connect to the database, something is messed up. Here's what I've got going at the moment. [ Mac OSX 10.6.6 -- Ruby 1.9.2 -- Rails 3.0.5 -- MySQL 5.5.10 ] All of these are the latest versions, freshly installed, and running smoothly. I also have rvm installed. All I want to know is how I can set up a new

alt text not showing when hovering over image

巧了我就是萌 提交于 2020-01-13 09:11:20
问题 i have the following code: <td><%= link_to(image_tag("delete.gif", :size => "16x16", :alt => "Delete Entry"), phone, :confirm => 'Are you sure?', :method => :delete, :remote=>true, :class=>'delete_phone') %></td> in my view. Now, it all works fine and does what I need it to, but when I hover over the icon, well, it doesn't show me any text. I've tried in Firefox and Chrome. Has anyone else come across the same issue? Thanks! 回答1: #protip - it can be a painful (and very un-DRY) exercise to add

Errno::EIO: Input/output error - <STDOUT>

扶醉桌前 提交于 2020-01-13 08:15:02
问题 class FaxFetchWorker include Sidekiq::Worker sidekiq_options :retry => false def perform(job_id=0) logger.warn "perform is invoked." FaxSource.all.each do |source| ... end end end Getting Error Errno::EIO: Input/output error - <STDOUT> on Line # 6 回答1: The #6 line in your code is this logger.warn "perform is invoked." This code needs opened STDOUT stream and your error name is Errno::EIO . In linux EIO means, that there was made an attempt to read/write to stream which is currently

Errno::EIO: Input/output error - <STDOUT>

不羁岁月 提交于 2020-01-13 08:14:37
问题 class FaxFetchWorker include Sidekiq::Worker sidekiq_options :retry => false def perform(job_id=0) logger.warn "perform is invoked." FaxSource.all.each do |source| ... end end end Getting Error Errno::EIO: Input/output error - <STDOUT> on Line # 6 回答1: The #6 line in your code is this logger.warn "perform is invoked." This code needs opened STDOUT stream and your error name is Errno::EIO . In linux EIO means, that there was made an attempt to read/write to stream which is currently

Detecting changes in a rails has_many :through relationship

戏子无情 提交于 2020-01-13 08:12:10
问题 I have a model that has a number of has_many, and has_many :through model relationships. For example, in my User class I have: has_many :languages, through: :profile_languages What I would like is to be able to detect when these are added or removed using the 'User.changes' function, which returns an array of attributes that have been changed when called with the User.language_ids= function. Has anyone else tried to do this, or have experience with this? Info on the ActiveModel changes

“gem install rails” give FilePermissionError with rbenv on mac OS X

别等时光非礼了梦想. 提交于 2020-01-13 06:35:26
问题 I've read all the other Stackoverflow posts on this problem but don't see any suitable solution for rbenv, so i'll post it on here. (most of the other posts suggest either using RVM, or the OP had already ran sudo gem install rails ). when i run gem install rails (without sudo ), i get ERROR: While executing gem ... (Gem::FilePermissionError) You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory. is /Library/Ruby/Gems/2.0.0 the correct spot? why am i getting this error?

Rails - How to include the mail_to helper inside of a controller

余生颓废 提交于 2020-01-13 06:10:12
问题 in my controller I need to format a json object, which is why I need to include several helpers. So far I have the following in my controller: include ApplicationHelper include ActionView::Helpers::TextHelper include ActionView::Helpers::TagHelper This works great for simple_format, problem is when the comment.content has a email address, rails trys to do a mailto link which breaks, showing the following error in the logs: "NoMethodError (undefined method `mail_to' for...." Any ideas on how

How to make passwords optional using Devise?

拥有回忆 提交于 2020-01-13 05:35:07
问题 How can I make the password optional into the registration and login when authenticating a user (if no password then it will just use the e-mail) using Devise. Although if they register with a password (or update it later) it should then be require for login. How can I accomplish this using Devise? Note: I'm using Rails 3.0.1 and Devise 1.1.rc0 回答1: Found in the devise email group by Nat Budin: class User < ActiveRecord::Base devise :database_authenticatable, :validatable protected def

Connection refused - connect(2) with rake db:seed on Mongodb

馋奶兔 提交于 2020-01-12 19:38:35
问题 I am using rails 3.2 and mongoid . I make these steps for setting my database: // Add an Admin User (to the admin db) use admin db.addUser("theadmin", "anadminpassword") // Use your database use superuser // Add a user (to your database) db.addUser("John", "passwordForJohn") // show all users: db.system.users.find() // add readonly user (kinda cool) db.addUser("readonly", "passwordForJohn", true) In my mongo.yml I have: production: host: localhost port: 27017 username: John password:

Using raw sql queries in Rails 3 application?

烈酒焚心 提交于 2020-01-12 16:10:36
问题 I am working on migrating a legacy database into my Rails application (3.2.3). The original database comes with quite a few long sql queries for reports. For now, what I would like to do it use the sql queries in the Rails application and then one by one (when time allows) swap the sql queries to 'proper' Rails queries. I have a clinical model and the controller has the following code: @clinical_income_by_year = Clinical.find_all_by_sql(SELECT date_format(c.transactiondate,'%Y') as Year, date