ruby-on-rails3

How does StackOverflow implement its revision history?

If I were to implement a system identical to the StackOverflow question revision history using Ruby on Rails, what would I need to do in order to achieve that? I am creating a site that acts like a wiki where user contributed content can be updated by other people. I need to be able to track the history of these changes, but I am not fam...

Rails 3 my custom BufferedLogger

I would like to define a custom logger for my Rails 3 app, in a way that it does not replace the original logger (I still make use of its information). I assumed that I could define in a lib a class that inherited BufferedLogger as I've seen on some blogs. Then I would instantiate a variable to represent my logger, on the end of my appl...

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 ...

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 ...

[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...

Rails 3 Observer -- looking to learn how to implement an Observer for multiple models.

Hi! I have the following Observer: class NewsFeedObserver < ActiveRecord::Observer observe :photo, :comment def after_create(record) end end What'd I'd like to learn how to do is add a SWITCH/IF statement in the after_create, so I know which model was created Something like: after_create(record) switch model_type case "photo"...

Rails 3 - Oberserver - Not able to user the Devise @current_user

Hello, Im building a Rails 3 app, and have an Observer... in the observer I need to user the current_user var that DEVISE allows me to user across my views... How can you use the current_user.name or current_user.id in the Observer? Thank you ...

response.should have_text leads to undefined method `has_text?'

I would like to test a controller that directly renders some JSON output (by using "render :json => @entity_names"). For that task I tried in my spec file "response.should have_text('["enim", "enita"]')". Unfortunately I always get that error: Failure/Error: response.should have_text('["enim", "enita"]') undefined method `has_text?' for ...

Generating two objects in one form. How to validate both are present?

I have a form for @profile (controller = profile#new). Inside this form are nested fields for generating an @user (I'm using Devise for user authentification). If a profile were to be generated without a user this causes lots of issues in the system so I want to set up a validation ensuring that a profile cannot be created without a u...

Rails 3 - Getting NameError after accessing models via has_many

Hey folks, I have following models: class App::Module::Object < AR::Base has_many :objects, :class_name => 'App::OtherModule::Object' end and class App::OtherModule::Object < AR::Base belongs_to :object, :class_name => 'App::Module::Object' end Using Rails 3.0.0 and Ruby 1.9.2, I get following error after accessing App::Module...

Rails 3 - polymorphic_path - How to Create One given a table

Hello, i have table AuditLog with fields including: audited_id | audited_type That results in data like: 108 | Photo 303 | Comment What I want to do is create a link to the item, so for the example above: here is the photo I'm trying to use a polymorphic_path but am getting an error: "undefined method `model_name' for Fixnum:Class" ...

Alternate editor for RefineryCMS

I think the build in editor isn't really that great and I think about changing it into something different. Is there any complete solution with one of the rich javascript editors available? Basicly it should be fairly easy to replace the editor with something else, as it just generates html. One thing which can a bit more difficult is r...

No route matches error for product_path in Rails

I have a resource called products and I believe it should create url helpers for products_path ("/products") and product_path ("/products/1"). While I get the first one, I cannot use the second. The error message says: No route matches {:controller=>"products", :action=>"destroy"} It appears to think I want to use the destroy actio...

How to vary a helper called within a Rails 3 layout, depending on the controller

I'm using the same layout for several controllers, and inside this layout I include a menu using a call to a helper, like this: <%= side_menu %> What I'd like to do is vary the contents of side_menu depending on the controller that's invoking the layout. In an ideal world, I could define side_menu in application_controller.rb and in ...

Rails routing error after fresh install

I just installed Rails, etc. on a Windows 7 machine. Created my first app, and am trying to go to the first generated and this is what I get: Routing Error No route matches "/say/hello" Where say is the app name, and hello is the name of the first view. Thoughts? ...

Rails3 Partial Question

I have an issue with routes when i use this partial partial search <% form_tag search_path %> textfield submitbutton <% end %> Then inside of my main index, i call the render 'partial' then when i try to use the text field i get a routing problem but in my routes i have match 'search' => 'dashboard#search' ... Any he...

Rails 3 - Installation Problems...Could not find bcrypt-ruby-2.1.2

Hello, I'm working to install Rails 3 on a new MacBook Pro... when trying to get my app going, I get the following error: Could not find bcrypt-ruby-2.1.2 in any of the sources Try running `bundle install`. When I run bundle install, I get the following: ... Installing bcrypt-ruby (2.1.2) with native extensions /Library/Ruby/Site/...

Rails 3 User Authentication (User Types)

Are there any particular rails user authentication gems or plugins that are well-suited for multiple user types? ...

Observe_field in rails 3

I had a dropdown. I need to add a textbox when the value changes in the dropdown. I had done this using "obseve_field" tag in rails 2.3.5. Now I am moving into rails 3. So how I write it in rails 3. ...