ruby-on-rails

When switching to jQuery, which validation framework is used?

When you switch the js framework in RoR to jQuery, what validation framework is used? ...

Best way to restict actions (edit/delete) with Ruby on Rails and Devise

I am fairly new to Ruby On Rails and right now I am doing a simple app. In this app a user can create many items and I use devise for authentication. Ofcourse I want to make sure that you are the owner in order to delete items (Teams, Players etc) and the way I do it now is: def destroy @team = Team.find(params[:id]) if current_...

Where can I get some really good video Rails tutorials - for free?

I know lynda.com has them, but you have to pay. Anybody know of any good ones for free? Thanks. ...

Date ranges: inclusive vs strict boundaries

When allowing a user to select a date range, let's say: Show me entries from [August 1] to [September 1] As a user, I would generally expect this to include the results for September 1. Especially when you consider that when I select the same date for both ends, I obviously mean "from start of day to end of day": Show me entri...

Converting Rails 2 plugin to Rails 3 gem

So there's this great plugin I've gotten used to using in my Rails 2 projects called Bootstrapper. It essentially duplicates the functionality of the seeds.rb file, but I like it because it lets you break up your bootstrap process into concise chunks. Anyway, I've gone so far as to fork the project and attempt to turn it into a Rails 3 ...

PayPal IPN Stopped Working 422 Error

I was using PayPal Web Standard and receiving IPN notices from my payments perfectly fine for a couple months. Earlier this week it stopped working. I have not changed any of the code for the function in sometime. I figured I would try here as a last resort as PayPal support pretty much just said, "not our problem". I'm using ruby 1....

Modifying attributes on the join model with accepts_nested_attributes_for

Simply, a Contact can have various associated Time Windows, which may or may not be Active as a Schedule. To wit: Models class Contact < ActiveRecord::Base has_many :schedules has_many :time_windows, :through => :schedules accepts_nested_attributes_for :schedules, :allow_destroy => true end class TimeWindow < ActiveRecord::Base ...

sql left join where rails

Because I use rails I've become rusty on sql since I rarely use it in rails. I have two related tables: comments 1:m comment_views I want to find all comments where comment_views.viewed is false. Problem is, for some comments there is not a relating record in comment_views yet. So far I have select comments.id from comments ...

Rails 3 Serialize

Hello, I'm looking to learn how to serialize data in Rails 3... Things I'd like to learn: A. What serialized data looks like (example for photo_id: 123123, photo_name: "Blah) B. How to serialize data in Rails 3 C. How to extract serialized data to do something like mydate.photo_id given the above. Thanks! ...

Rails 3 - How to Create a JSON Object to store in the database

I'm creating an AuditLog observer that watches over several models. I'd like the observer to have an after_create, which creates a JSON object that is stored in a database column. It will contain data like {photoid:123, photoname: "asdasd", creator_id: "asdasd"} etc... In Rails, how do I create this type of JSON object and then how do ...

Is there any tutorial I can find about Multiple Table inheritance with Rails ?

I could not find any tutorial ...

Passing fullstops (periods) and forward slashes in a GET request?

I have built a form that submits values to Wufoo as a GET request in the URL. I cannot get it to work if any of the values (in a textarea) contain a line-break or a forward slash. Is there a way to encode these in a URL?? This is being done in Rails. Many thanks in advance, Galen ...

Question about URL friendly links

Hi, I am trying to get my urls to look like this: example.com/posts/id_of_post/title_of_post I have this in my controller: match ':controller/:id/:link', :controller => 'posts', :action => 'show' Say I have a list of posts.. how can I link to them? <%= link_to 'Show', post %> Just gives the usual /posts/id On another note, at t...

What is the most logical method to decide upon a value given a set of nested rules? and how do we store it?

Hi there, I'm needing to implement what to me looks like a decision tree (though searching on that term returns posts on finding out influencing factors in a decision process - which isn't what I'm after). The system I'm building will be working out warranty periods to give a product installation based upon some criteria. The requireme...

what do an undefined method [] mean in rails?

Hi, I get the following error: undefined method `[]' for nil:NilClass The related snippet in line 50: 47: <%=h @contact.date_entered.to_date %></br> 48: Next event: 49: <% next_delayed_todo = @contact.next_delayed_todo %> 50: <% unless next_delayed_todo[:event].nil? %> 52: <%= next_delayed_todo[:event].title %> </br> ...

How to write a view helper that renders works with HAML and ERB?

Hi I am working on a gem that defines a few view helpers and it heavily relies on concat and capture methods but I've recently discovered it doesn't work with HAML (haven't tested thoroughly, but so far doesn't render concat(nated) stuff). I read somewhere there was a haml_concat version of concat. So If I just need to change my concat ...

[rails3] permanentredirect s3 for unspecified endpoint

I'm experimenting with s3 but im running into a permission problem (i think). Output: AWS::S3::PermanentRedirect in CkeditorController#create The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint. I'm using ckeditor. My Ckeditor::Picture class includ...

CSV-Mapper No such file or directory

I am using the csv-mapper gem to import a csv file. When I use the example code on in the README (http://github.com/pillowfactory/csv-mapper) in script/console it works great. However, when I create a web form and use that to upload a csv file I get the error "No such file or directory - test.csv These are the parameters: Parameters: {...

Search in Rails using find

@user_post = Post.find(:all,:conditions => ["content LIKE ?", "%#{params[:query]}%"]) This particular statement returning nil even though there exists a record in the database. Where could be the problem? Please help me out. ...

Conditional code in the define_method block

I am generating some methods on the fly. The method body varies based on a certain criteria. I was relying on class_eval to generate conditional code. %Q{ def #{name} #{ (name != "password") ? "attributes[:#{name}]" : "encrypt(attributes[:#{name}])" } end } Recently I have started using define_...