ruby-on-rails3

Rails 3 with Uploadify & Paper_Clip

Anyone here haveRails 3 with Uploadify & Paper_Clip experience? I'd like to allow the user to upload photos: Here is my view: <input id="fileInput" name="fileInput" type="file" /> <script type="text/javascript"> $(document).ready(function() { $('#fileInput').uploadify({ uploader : '/uploadify/u...

inherited_resources and cancan conflict

Hi, There are conflict with inherited_resources and Ryan Bates's cancan gem. I have some simple controller class IssuesController < InheritedResources::Base respond_to :html load_and_authorize_resource def tag @issues = Issue.tagged_with(params[:tag]).recent.paginate(:page => params[:page]) end protected def collec...

Rails cache sweeper doesn’t work with nested models

This is for Ruby 1.8.7 & Rails 3.0.1. I have a model TeachingGroup, which belongs to current_user.current_term. A Sweeper exists with: class TeachingGroupSweeper < ActionController::Caching::Sweeper observe TeachingGroup def after_update(teaching_group) expire_cache_for(teaching_group) # elsewhere, working end ... # other ...

ActiveModel based class does not create the same results as an ActiveRecord equivilent

Hi, I am developing a Rails 3 app in a largely tabless capacity. I am using savon_model and ActiveModel to generate similar behaviour to ActiveRecord equivalents. Below is my code: class TestClass include Savon::Model include ActiveModel::Validations # Configuration endpoint "http://localhost:8080/app/TestService" namespac...

rails 3 best approach multiple apps within one app

I have a rails 3 app that has 2 different UIs that both share the same model but have different UIs. Lets call these retailers and customers "sites". What is the best approach in rails 3 for creating a monolithic application to keep these two apps in one app. Should I just namespace the controllers, and change routing as such? namesp...

Rails - Find or Create based on TimeStamp? possible?

Hello, In my controller I'd like to do something like the following: @book = Book.find(:all, :conditions = > [" created_at > with in the last 1 minute "] if @book.nil? # Just incase we didn't create a book, we'll initialize one @book = Book.create() end @chapters = @book.chapters.build etc............. * In sum, when the user i...

Ruby on rails form input error formatting

The default behavior for a regular rails form that has errors is to 1) list the errors in a div, with the text coming from errors_for and 2) to place a div around the offending inputs with a red border. This question is concerning #2. I'd like to know how rails goes about applying that div with the red border. I'd like to know because...

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

Devise: How to create a private admin role?

I have a simple Rails 3 blog app that needs an admin user so I can restrict creating and editing blog entries to the admin. I've used devise before, but only for users that are public and can be created by anyone. I don't want the ability to create an admin to be publicly accessible. How should I configure devise to be able to have an ad...

Problems upgrading to Rails3

I'm upgrading a rails 2.3.4 app to rails 3, and running into a few problems. For the most part, I can get my app running, but some of my monkey patches don't work. I can't reference a constant defined in my lib folder in application.rb. I have the line: config.autoload_paths += %W(#{config.root}/lib) which properly loads the files...

Save active_record without calling callbacks in rails3

In rails 2 there was a private method on active_records called create_without_callbacks which you could call to save a record into the database without triggering the callbacks associated with that object. This method has disappeared in rails 3, is there any way to achieve the same thing? ...

Rails 3 On Ubuntu

Hi there everyone. I'm new to linux and newer to rails. I installed ruby 1.8.7 which is compatible with rails 3, i did the gem update and it installed for me rails 3.0.1 and all necessary files. However when i make a new rails application using the 'rails new myapp' command i notice that the script folder only has one file 'script/rails'...

Ruby interface for sqlite3 fails , need help !!! :(

I was trying to install sqlite3 interface for ruby in my Ubuntu 10.10. But i got the following error any suggestions ? ERROR: Error installing sqlite3-ruby: ERROR: Failed to build gem native extension. /usr/bin/ruby1.8 extconf.rb extconf.rb:3:in `require': no such file to load -- mkmf (LoadError) from extconf.rb:3 ...

Rails attribute values from several other tables

If I need to create a model which will have several fields coming in from other tables and I want the field values to be dynamic so that users can add more values just like tags.Is there Any Plugin or method to handle all this in a good way rather than coding it in For example if I have a table of cars, I might have fields in it named c...

Rails 3 -NoMethodError (undefined method `original_filename

Hello! I'm using Rails 3, Uploadify, to send images to S3. Right now all the images being upload have the MIME: application/octet-stream I'd like to fix that but I'm getting the following error: NoMethodError (undefined method `original_filename' for #<ActiveSupport::HashWithIndifferentAccess:0x107c81998>): app/models/photo.rb:29:in...

How do I model these relationships?

I have a contact model, this includes name, address, phone number, etc. I have a user model which should have_one contact. I have a Customer model which has_many contacts. I have a Producer model which has many contacts. A contact can be only a user, a user and a customer, a user and a producer, or any combination of these three. I a...

Must I always use a form in a tabular interface in Rails?

I have a list of users that have requested access to my application. They appear in a table inside a view: <table> <thead> <th>Company</th> <th>First Name</th> <th>Last Name</th> <th>Email</th> <th>Role</th> <th>Action</th> </thead> <% for ar in @brand.access_requests %> ...

Resque worker gives out "NoMethodError: undefined method `perform`"

Hiya, I have no idea what I have done here, but I have attempted to get one controller in Rails to queue a job onto Resque, which then a worker connects to and does the heavy lifting (I.E. comparisons, database entries). However, the tasks are not even running, since there are no clear instructions for setting Resque up. Copy and paste'...

rails3: build child record

Hello, I have 3 models: user, wish_list and wishes: user has_one wish_list wish_list has_many wishes On my index page, I'm listing all the wishes of my current_user's wish_list in my controller's index method: @list = current_user.list @wish= @list.wishes.build in my index view, I want to put a form to add a new wish on top ...