ruby-on-rails

Missing the Rails 2.3.4 gem. Even though it's installed!

Running Snow Leopard. Tried uninstalling, and re-installing. Still getting the same error whenever I run a rake task. mbpro:redmine shereef$ ruby -v ruby 1.8.7 (2009-06-12 patchlevel 174) [i686-darwin10.0.0] mbpro:redmine shereef$ rails -v Rails 2.3.4 mbpro:redmine shereef$ which rails /usr/local/bin/rails mbpro:redmine shereef$ gem...

call upload controller, but error will appears

I'm coding with Ruby on rails 2.3.2 under BitNami RubyStack When i call the upload controller, i get error like this: compile error C:/Users/BitNami RubyStack projects/killerapp/app/views/upload/index.html.erb:6: unterminated string meets end of file C:/Users/BitNami RubyStack projects/killerapp/app/views/upload/index.html.erb:6: syntax...

Need help with polymorphic join table in rails

Hi gys i am trying to link two entities to one entity which is governing body, estate and repo_document, then a governing body can have repo_document that the estate can also have so i decided to create a join table named document_owner.. but i dont know what to write in their models..i have got this code in my document_owner model.. b...

Error while compiling view in Ruby on rails?

I'm coding with Ruby on rails 2.3.2 under BitNami RubyStack. When I call the upload controller, I get error like this: compile error C:/Users/BitNami RubyStack/killerapp/app/views/upload/index.html.erb:6: unterminated string meets end of file C:/Users/BitNami RubyStack/killerapp/app/views/upload/index.html.erb:6: syntax error, unexp...

Modeling Complex Relationships in Rails

UPDATE OK, I figured it out. I had to call the following for varieties: <%=h @user.varieties.find_by_product_id(product.id).name %> Here's my two follow questions: (1) Is this going to cause problems when editing/deleting records because I'm not calling the join model? I've seen some Ryan Bates videos where he stresses this po...

rails join table problem

Part of my RoR application is responsible for managing web site designs portfolio. One web site design can have many images associated with it. One image can be associated only with one design. I use has_many statement with :through parameter to connect images with design through join table. And when image is deleted associated entry ...

RESTful route for a list of members that are not in a collection.

Hey there, I'm trying to figure out what the best way to show a list of members (users) that aren't a collection (group). /users is my route for listing all of the users in the account /group/:id/members is my route for listing all of the users in the group /users?not_in_group=:id is my current option for showing a list of user...

Can I use associations when using Ruby on Rails w/Amazon SimpleDB?

For a new project my company is considering using Amazon SimpleDB to simplify data storage. The app is a simplistic web dashboard that will be created using Ruby on Rails. What I'm wondering, though, is if I can still use associations like has_many and belongs_to while using SimpleDB as the backend. For instance, the application has u...

Using syslog in rails application

I am thinking of using syslog in my rails applications. I am going to follow instructions mentioned here In production box I have 4 rails applications running using passenger. If I switch to use syslogger for all 4 of my applications then I am afraid that the log messages from all 4 applications will go to a single file and the log mess...

Refactoring DB Migrations in Ruby on Rails

When project grows up, the number of migrations starts to be pretty high, and as I look back, I see many migrations that could be refactored. Like merging create_posts and rename_posts_to_responses into create_responses. Is this a bad habbit or should I encourage refactoring migrations? ...

Rails: Elegant way to structure models into subfolders without creating submodules

I have numerous models in my app/models folder. I'd like to clean this folder up a little bit. Move models that belong to each other in subfolders. The problem is that by convention the model class is namespaced into an according module. E.g. app/models/blog/post.rb app/models/blog/comment.rb app/models/user.rb so that: app/models/b...

Convert fixtures into Factory Girl in Rails

I'd like to migrate my fixtures to "Factory Girl" in Rails. Is there any easy way to convert all yml files in a factories.rb file? ...

RoR: AssociationTypeMistmatch with Hidden fields

Hello there, I got followup tasks and notes. A note might have a followup task So when im creating a task, it might bring task.note with a value or null I getting some problems on retriving this note id I'll post the log <% task = task_item_new %> <% n = Time.now.to_i %> <div class="new_div" id= <%="task_item_#{n}"%>> <% remote_fo...

In Ruby on Rails is there a way to view the properties of a model

I am using NetBeans to create my first Ruby on Rails application. Is there a way by which I can view all of the properties of a model? Should I just be looking in the database? ...

Using will_paginate with named_scoped

I have been having problems when using pagination along with named scope. The second page or any consecutive page of pagination using named_scope still returns result from the first page. Using find(:all) returns the pagination result correctly. Has anyone been able to use both them both correctly or experienced the same problem? clas...

Partials and local variable

If we want to pass a collection to partial, we do like this: <%= render :partial => "post", :collection => @posts %> If we want to pass a single object within a custom variable, we do this: <%= render :partial => "item", :locals => { :item => @advertisement } %> Now what should I do to to pass a collection, "proxying" it through a ...

Active record organisation for maintainability and testability

Hello friends! Some of my AR classes are starting to... bulge around the waist. I'm starting to think it might be time to put them on a diet. Probably the biggest concern I have is that there's just so much code in one file, I'm considering breaking out validations, associations and groups of related methods into modules. Are there a...

ActiveRecord table inheritence using set_table_names

Hi, I'm using ActiveRecord in Ruby on Rails. I have a table named documents(Document class) and I want to have another table data_documents(DataDocument) class which is effectively the same except for having different table name. In other words, I want two tables with the same behavior except for table name. class DataDocument < Docum...

Intermediate model to join two seperate models in Ruby on Rails

I am trying to create an intermediate model between two models that I'd like to have a many to many relationship. I am creating an atypical book checkout project and have two models setup Book and Person. I'd like to setup an intermediate model BookCheckOut to track OutDate and ReturnDate. Dan Singerman provided what looks like the answ...

before_add callback using nested_attributes

Given the following: Foo has_many :bars, :through => :baz and Foo accepts_nested_attributes_for :bar I want to do a find_or_create_by_name when I add a new :bar, but I don't know where I can have some sort of before_add functionality. The background of this question is Bar validates_uniqueness_of :name, which gives errors when I try...