ruby-on-rails

How to create password and confirmation when using form_for?

I am using form_for, but I'm not sure how to create the password and password confirmation using the helpers? I have so far: <%= form_for :user, @user, .... do |f| %> <%= f.text_field :user_name, :class .... %> password?? <% end %> Also, when posting to the /user/create action, how to do I prevent certain fields in the model fr...

Rails: Best association model for Users ->posts -> comments model in a forum kinda of website ?

I'm creating a forum website, where each registered user can write many posts and each post can have many comments. Also each user can comment on any posts created by any-other user. has_many has_many user ------------> Posts -------------- > Comments | ^ | ...

Paper_clip s3 - application/octet-stream ?

Hello, All my rails paper_clip images are being uploaded to Rails as "application/octet-stream" Which is casuing issues. How in Rails do I set the content/type to the right type? Image/png etc, based on the actual image being uploaded? Thanks ...

RoR pattern for a registration page

I have a action/view named: join And I post the the 'create' action. What should my create action look like, I want to pre-populate some fields if the creation process had an error in it (like say the email address). So far I have: def create @user = User.new(params[:user]) if @user.save end end ...

accepts_nested_attributes_for validation

I'm using Rails 2.3.8 and accepts_nested_attributes_for. I have a simple category object which uses awesome_nested_set to allow nested categories. For each category I would like a unique field called code. This would be unique for the category per level. Meaning parent categories will all have unique codes and sub categories will be ...

Rails - any plugin/gem for creating calendars

Hi, I was trying to find a gem or plugin that had a cool looking calendar control. Is there anything that someone can recommend? Is there a way to display a set from 2 different months like dec. 11 - jan. 11? ...

What does this instruction in the Bundler setup mean?

I'm trying to setup Bundler with Rails 2.3.10 to make the transition to Rails 3 easier. But I'm not sure what the instruction on this page means. Am I supposed to require all the gems that I'm using in my app? If so, where? Thanks for reading. ...

Going strictly RESTful on Rails

I'm working on a gaming app (mobile front ends, Rails backend) and trying to decide if I should go strictly RESTful. It appears that I'll be creating a lot more controllers if I do so. For example, there are several game actions I need to implement like attack, defend, etc. If I go strictly RESTful, I'll need to create a controller for e...

Missing interpolation argument error in Redmine

A bit of Googling led me to believe that this error happens in Rails Version < 2.3.6 . So i changed my environment file to RAILS_GEM_VERSION = '2.3.8' unless defined? RAILS_GEM_VERSION Now, I have 2 questions . I continue to get the redmine error. When I do a script/server, I get this : Rails 2.3.5 application starting on http://0...

Redbox not working with forms - alternative?

I've installed Redbox, a lightbox solution for rails. It works fine, but I'm trying to use it for a form. Part of the form is in my view, but part of the form and the submit button are in the box: <div id="confirm", style="display:none;"> Are you sure you want to go?<br><br> <%= f.check_box :...

Rmagick image resizing problem

Hi, I am using attachement_fu plugin with Rmagick image processor for uploading images. Even though I am able to upload images properly there is some problem with the thumbnails. Thumbs are created with same size as original image. Also the height and width of images are saved as null in database. Here is my model. has_attachment :sto...

Writing templates without using html for ruby on rails/django

I hate to explicitly use html/css to build pages. Is there a template language I can use to semantically and quickly describe the layout and content of the page so that later I can generate html and css from it? I'm planning to use this on a django site (but I guess if such solution already exists for RoR I can always adapt it). Thank...

Is there a Ruby, or Ruby-ism for not_nil? opposite of nil? method?

I am not experienced in Ruby, so my code feels "ugly" and not idiomatic: def logged_in? !user.nil? end I'd rather have something like def user.not_nil? end But cannot find such a method that opposites nil? ...

How do :default => 0 and :null => false differ for integer fields in migrations?

If I use a migration to update a database, and I add an integer field like this: t.integer :foo :default => 0, :null => false What is the default state of existing and new records in the database? I hoping the answer is: - Both will read back foo as 0. Is default => 0 necessary, if I have :null => false? Just trying to understand t...

ActiveRecord Association without Foreign Key

I am trying to build a relationship model between users. A user can either initiate a relation, or receive a relation from another user. Therefore, the relations table in the db has the foreign keys "initiator_id" and "recipient_id". Now, I can figure what relations the user initiated or received using the following associations: has_...

onchange error for select table

Hi, I am trying to add onchange handler to see which select option is currently selected and put it in a file. How can I do this? <select id="subtable" name="subtable" size="20" style="width: 400px"> <%= options_from_collection_for_select(@hauses, 'id', 'timebuild', @hauses.first.id), {}, {:onchange => catch()} ) %> </select> wh...

pattern findings using "find" in Rails

Hi, This is my current code @descriptions = TableName.find(:first, :conditions=> ["table_id = ?", table_name.table_id], :order => 'author_year') author_year column contains data of kannan 1845 kohlun 1976 palani 1956 Using above code, it gives result with order of author_year based on author names. I need to order the query asce...

Ruby on Rails: where should I store modules?

I am new to Ruby on Rails and my questions are about the application design, based on Rails 3. There are many data on the internet on the creation of standard websites (such as blogs) on Rails, but my application requires more than just "post and read" and I am not sure how to implement that. The idea: The model "Route" includes a num...

libxml makes a difference between " and "

Hello Everybody, I encounter a unbelievable strange problem: The libxml parser I'm using makes a difference between " and ". Is there one? The following attribute makes the error: name="New Headway_the third edition" if I replace the " character with the " I enter with my keyboard everything is working fine... I allready proved,...

How to solve this problem--OAuth2::HTTPError: Received HTTP 400 during request problem with facebook_oauth in production server in Ruby on Rails??

I am getting this exception with facebook_oauth 0.2.0 in production server ----------- OAuth2::HTTPError: Received HTTP 400 during request.> Received HTTP 400 during request. /usr/local/ruby-enterprise/lib/ruby/gems/1.8/gems/oauth2-0.1.0/lib/oauth2/client.rb:80:in `request' /usr/local/ruby-enterprise/lib/ruby/gems/1.8/gems/oauth2-0.1.0/...