ruby-on-rails

Rails and Amazon SimpleDB authentication

Hello, I'm trying to use Amazon's SimpleDB with RoR. I need a standard user registration / authentication / roles checking. Pretty simple, but it seems that restful-authentication plugin did't work with SimpleDB. Can someone please point me to working solution or should I write my own from scratch? Anyone? Please? ...

Rails Ajax Authentication

Hello, Does anyone know if it is possible to create a secure authentication system using AJAX? I would use the same recommended security techniques, except that the user name and password would be posted using AJAX. If anyone has any ideas on why this would not be secure, or if they could point me to any resources that discuss this I ...

Rails datetime_select ignores invalid values

I am using rails 2.3.4 . In the datetime_select helper if I select Feb 31 then I do not get any validation error. That is just wrong. What is the best way to intercept the parameters and to present to user that there is validation error. ...

Rails app reports crazy 'DB' times, or is maybe hung up in the mysql layer?

At some point in the past week, my production logs began showing bizarre numbers that don't ad up, like: Completed in 52ms (View: 26, DB: 1129) This query did take over one second. But, there was no database activity - no sql queries shown in mysql log nor rails log. So, somehow the Rails app is spending a tremendous amount of time d...

Can I tell activerecord to not convert "datetime" data to objects when I access?

I have some code that simply accesses a datetime field so activerecord converts it to a Time object automatically when I read it: @some_appointment.some_time The problem is that sometimes the "some_time" datetime column has bad data. "0209-12-20" instead of "2009-12-20". This causes to Ruby to throw a "year too big to marshal" error...

Change rails text_field form builder type

I've been looking at the new options available in HTML5 forms, such as declaring input types as "email", "url", and "number", as described here. How can I use these in conjunction with the rails form builders? I have tried <% form_for @user do |f| %> <%= f.email :email, {:placeholder => '[email protected]'} %> <% end %> But that does...

versatile blog for ruby on rails, password protection?

Hey guys, I am making a personal website with a blog. I'd like to have certain entries password protected like I've seen on at least one wordpress. That's no biggie. But I was wondering if there was something really flexible which will allow hidden text to be revealed after a post? For example, the public post may say, "I met my friend B...

Managing CSS in large Rails projects

What are some good methods for handling CSS in large Rails projects? Ideally I'd like to be able to include CSS or a link to a CSS file per partial. I've played around with using content_for and yields which allows me to insert CSS into the head of the page with partials that are located elsewhere, however some partials get used more th...

Does/can Passenger use clusters like Mongrel?

I'm just curious if Passenger does or can utilize clusters like Mongrel can. If so, how can I specifically run Passenger with clusters? I'm using nginx. And if not, how does it outperform Mongrel so well? ...

Convert string to symbol-able in ruby

Symbols are usually represented as such :book_author_title but if I have a string: "Book Author Title" is there a built in way in rails/ruby to convert it into a symbol where I can use the : notation without just doing a raw string regex replace? ...

inserting superclass in rails, without corresponding database table

I'd like to have a common superclass for two models in ruby, to share several methods. Let's say I want a Truck and Car inheriting from Vehicle. Here are some options: Make class Vehicle < ActiveRecord::Base, and have class Truck < Vehicle etc. But then I get errors saying I don't have a table for Vehicle (and I don't want one, either)...

how to remove event attribute from html using Hpricot ?

I want to remove a list of dom events attribute from html? how to do this? like: before = "<div onclick="abc" >abc</div>" after = clean_it(before) // after => "<div>abc</div>" DOM_EVENT_TO_BE_REMOVE = "onclick|ondblclick|onerror|onfocus|onkeydown" // i want to remove these events // i want to do it like this def clean_it(html...

Adding a custom method to a model attribute?

Is this any possible? I'd like to have something like User.avatar.to_url which would then print the full URL address for the user's avatar image. => "http://url.com/images/avatars/1262694724.jpeg" Of course, the avatar attribute would be an existing column on the users table which contains a long integer. The to_url method im th...

How can I display the 1 to many and many to 1 relationship in RoR?

I have a table called "order" which has many "order_items" , each "order_items" is belongs_to "order" and "product". In the db, I have one record in order. the record is like this: orders table: id = 1 name= customer and the order_items table is like this: id=1 product_id=233 order_id =1 id=2 product_id=454 order_id =1 I have the ...

Problem with value feteched from params[] in rails

Im making a calendar to display some entries and it needs to select the month and year, i use this in the controller to achive that: def index @month=params[:month].to_i || Time.now.month @year=params[:year].to_i || Time.now.year @months=[nil, "January", "February", "March", "April", "May", "June", "July", "August", "Sept...

requeue a sweatshop job in RabbitMQ

I am working on a Rails application where customer refunds are handed to a Sweatshop worker. If a refund fails (because we cannot reach the payment processor at that time) I want to requeue the job. class RefundWorker < Sweatshop::Worker def process_refund(job) if refund Transaction.find(job[:transaction]).update_attributes(:sta...

Ruby on Rails : symbol as argument in form_for

I understand what is passed to the form_for method when doing something like : <% form_for(@user) do |f| %> ... <% end %> if @user is set in the controller. This is pretty obvious. But what happens when we pass :user, as I have seen in many examples ? <% form_for(:user) do |f| %> ... <% end %> When should I use the symbol version ...

Rails Hosting for Non-Profits

Does anyone know of rails hosting companies that will offer a free plan for non-profits to get up and running. I am sure it would only be free to a certain point (bandwidth, disk, etc.) but would like to explore the options. ...

Web service is giving "illegal refid function"

We are calling a PHP web service from a Rails app using RPC. This was working fine. We had some offshore PHP programmers modify the web service and now this portion of the app throws an error that says illegal refid function.require-once. Having never used RPC before, I am just a tiny bit confused. This would be an error with the PHP...

How to embed a tag using content_tag in RoR?

I have this to generate a hyperlink for me: <%= link_to "Example", "http://example.com" %> And I want it display in the td tag, so I want to use this content_tag to help me: <%= content_tag(:td,"", :class => "example")%> I want the hyperlink in my td, so I have something like this: <%= content_tag(:td,<%= link_to "Example", "http:...