ruby-on-rails

Best Practice to load default values to a database in rails

Hi All, I have a rails project where I need to add some default values to the database table. I want to know the best way of doing these (im using rails 2.3.3 which doesn't have seed.rb file :() 1 - Creating a sql script 2 - creating a migration 3 - creating a rake task 4 - other (Please explain) thanks in advance cheers sameer...

Rails 2.3 Action Mailer issue

Hi, I am using Action Mailer to send out emails when a transaction is reported. Even if a single user in the 'CC List' is not active on the exchange server, the email is not being sent to anyone in the list. I would expect it to send to everyone else and send a delivery failure notificationfor the user who is not active. Is this an addi...

When running rdoc the folders 'images' and 'js' are not copied to the doc dir

I am running rdoc 2.5.9 and when I generate rdoc with the default 'Darkfish' template just by running: rdoc app README in my rails root folder. All the files are generated but the 'images' and 'js' folder is missing in the doc directory. So I need to copy them manualy. I have the following versions: gem 1.3.7 ruby 1.8.7 Rails 2.3.8 ...

Accessing Rails RESTful routes in the model.

To clean up my code I would like access to the RESTful helpers in my Rails model. Something like: users_path etc. Thanks. ...

rails: user function link_user_accounts does get called but not entered

Hi there, Im about to implement facebook connect in to my rails application. One very strange problem is, that link_user_accounts does get called, but nothing gets executed... (debugger stops at def link_user_accounts and then jumps over the next debugger steps) def link_user_accounts if self.current_user.nil? User.create_from_f...

How can I sort the files on the basis of time stamp from the the below set of files?

File dir = new File("."); FileFilter fileFilter = new WildcardFileFilter("sample*.java"); File[] files = dir.listFiles(fileFilter); for (int i = 0; i < files.length; i++) { System.out.println(files[i]); } for example: If I have the files shown below in a directory: FILE NAME DATE CREATED/MODIFIED proper...

Rails: Empty has_many relations (for lack of better description)

Hi there, I'm sorry the title is kinda vague :-) I have a User model with associated Answers. Each of these answers is an answer to a Question: class User has_many :answers end class Question has_many :answers end class Answer belongs_to :question belongs_to :user end The questions are the same for all users, but their...

restful_authentication how to update to a newer version?

Hi everybody, I experienced problems with my older version of restful_authentication, to include the facebooker plugin. Is there a simple way to update the plugin? Thanks Markus ...

Uploading multiple files to a Ruby on Rails app: first file doesn't get uploaded.

For my Ruby on Rails application, I need the possibility to create several LectureNote objects at a time. I tried to do it with a view like this: <% form_for @lecture_note, :html => {:multipart => true} do %> <%= hidden_field_tag 'thematic_block_id', params[:thematic_block_id] %> <table> <% (1..8).each do |i| %> <tr> ...

Not able to create a spec file for the controller in Rails

Hi, I am new to ROR. I am working on Rspec.. I have been provided with a full package of an application. I kept it in my rails dir. The dir itself contains spec folder with some controllers/models and fixtures but without spec_helper file. So when i run $spec spec/ i got an error /usr/lib/ruby/gems/1.8/gems/rspec-1.3.0/lib/sp...

how can I make a drop down list in Rails 2.0?

Hi I have two models in Rails: invoices and products. Each invoice has one or many products. And each product belongs to one or many invoices. On the invoices view, I would like to select the product name in a drop down list. The list needs to contain all the products available. If I insert another product in the product view, this new...

Multiple has_many association through same table in Rails

I have following database schema: I want to be able to do something like this: dog.head << Feature.new(...) dog.tail << Feature.new(...) I am new to Rails, so I am not always sure by 100% what I am writing, but I tried following declaration of Dog class, and failed :) : class Dog < ActiveRecord::Base has_many :features, :through...

How to send emails through Ruby on rails in linux

I want to include a new module to my project where i can send some mails to my client.I don know how to include this emailing module . i searched in net but most of them have told to edit some SMTP.Where can i find this in linux.I am really confused about this.Plz guide me out.I need it urgently. ...

Session problem using Facebooker with Ruby on Rails

Hey everybody, I am reading the book Facebook Platform Development in order to try to code a small game for Facebook, and I have come across a "little" problem: I am trying to insert a user every time this is logged, into a database in my computer. I am using a couple of methods written in the book, but there seems to be a couple of pro...

Changing the RoR SQL call to NAME instead of *

Being that it is better to call a SQL database with the specific item, for example: Bad: SELECT * FROM tblUsers Good: SELECT email FROM tblUsers How would I do this in RoR to make it explicitly perform the latter example? ...

What is causing this difference between my Ruby on Rails console output and my Firebug console output when using a Ruby date object?

Can anyone explain the difference between the Ruby on Rails console output and the Firebug console output? event_controller.rb def list_events @days[1][:date] = (((Date.new(2010, 8, 6)) + 1).to_s) end list_events.html.erb <% @days.each_with_index do |day, i| %> <% p day[:date] %>; //RoR console console.log(<%= day[:date]...

Authlogic, multiple user types and multiple relations between the same models

Good morning, I'm trying to figure out the best way to manage this user situation I've got. I have users and affiliates. There is already a HABTM relationship between the two of them, because users can sign up for affiliates, and affiliates can reach out and touch users, in order to get various data points. Now I need to set up a new...

rake paperclip:refresh class=foobar from S3..

I am try to perform the function: rake paperclip:refresh class=foobar And it begins to work, but it looks like it gets hung up with this stack.. : ** Invoke paperclip:refresh (first_time) ** Invoke paperclip:refresh:metadata (first_time) ** Invoke environment (first_time) ** Execute environment ** Execute paperclip:refresh:metadata r...

Rails rake db:migrate aborts with generated model

Hello, Can someone tell me what I have done wrong? I ran script/generate model CityZipMSA city:string state:string zip:integer MSA:integer And then ran rake db:migrate and I get the following error (in /Users/MMyself/app_dev/property) rake aborted! An error has occurred, this and all later migrations canceled: uninitiali...

Find and replace entire HTML nodes with Nokogiri

Hi, i have an HTML, that should be transformed, having some tags replaced with another tags. I don't know about these tags, because they will come from db. So, "set_attribute" or "name" methods of Nokogiri are not suiteable for me I need to do it, in a way, like in this pseudo-code: def preprocess_content doc = Nokogiri::HTML( self...