ruby-on-rails

Rails 3 compatible image uploading with no dependencies?

OK so I'm looking for a good image uploading gem that is Rails 3 compatible and has no dependencies. I was using attachment_fu, but it's Rails 3 compatibility seems to be in question. And I really wanted to use Paperclip, but it has an image majick dependency. I'm having a hard time finding other alternatives... Stupid question #1:...

ruby's oauth2 grant_type

Hi, i started using oauth2 gem by intridea (http://github.com/intridea/oauth2) and don't know how to fix this problem. I have developed both client and server and on request for access_token i see no grant_type parameter. My code from client callback controller class CallbackController < Devise::OauthCallbacksController def accounts ...

Rails 3 widget helper partial

Hi! I ran into a big problem in moving my application to Rails 3. I have a view helper which i call 'WidgetHelper'. It helps to render some partials automatically when i refer to it. For example <%= widget('loginbox', :global => true) %> But it not works correctly. It renders HTML code as I want, but escapes the return value, what is...

Ruby on Rails' respond_to causing strange error

There is another respond_to for the usual case, and a special case when a param[:top] is passed in, so there is another respond_to earlier in the code: respond_to do |format| format.html { render :top_page_analytics } format.json { render :json => @analytics } format.xml { render :xml => @analytics } ...

Ruby YAML::load

I'm trying to modify the default deserialization of the built-in timestamp format, to affect Ruby's Time. I do this (successfully) with Hash: YAML::add_domain_type('yaml.org,2002', 'map') { |t, v| nil } YAML::add_domain_type('ruby.yaml.org,2002', 'hash') { |t, v| nil } hash = { :hello => :world } puts YAML::load(hash.to_yaml) # nil B...

How can I write an RSpec test for link_to_add_fields helper from Railscast 197

I used the approach details in Railscast espisode #197 on how to add dynamic input fields, but I'm not sure how to write an RSpec test for it. Suggestions? def link_to_add_fields(name, f, association, path, *args) new_object = f.object.class.reflect_on_association(association).klass.new fields = f.semantic_fields_for(association, n...

Is there any Rubygems or Rails method that can display how long it took to generate the webpage, and time in controller vs in view?

Alternatively, I can write a bunch of Time.now and print out the subtractions but is there a standard way it can be done by gems or by Rails' standard and conventional method? ...

Authentication for Rails 2.3.8 using MongoDB and mongo_mapper

Hi All, How will I do authentication using Rails 2.3.8 using MongoDB and mongo_mapper? Let me know your expert advise on this. By the way, a Rails noob here :) Thanks! ...

Ruby on Rails: how do you add a class in a link_to helper?

how do you get a link_to to generate something like <a class="myclass"..... this is my code <%= link_to "link", :controller => :my_controller, :action => :index, :class=>("on" if request.path =~ /\/my_controller/ ) %> ...

sortable.create: option "dropOnEmpty" not working inside a table with tbody element

I am trying to implement drag and drop functionality using "sortable.create" among 4 tables. The drag and drop functionality is working perfectly fine but is a particular table is empty then I am not able to drop anything inside it even after providing the option "dropOnEmpty: true". Let me know if you have encountered a similar problem...

How do I protect my private keys when using github, heroku, and developing locally?

Currently, I put the keys I use to access other API's and the like in the environment.rb file. That way it is available both when I run locally, and also on heroku. However, I'd like to start to make my code available publicly via github so i can get some help. What are the steps I need to do to make this happen, particularly so that ...

arel, how to join

Given class Category < ActiveRecord::Base has_many :products, :order => 'name ASC' end Using the Rails 3 stack, how can I query for all categories that 'have' products? ...

Rails: best way to validate and display error messages for fields not in model

In my Rails 3 application I have a typical 'Email this to a friend' form that has yours/friend's email and name fields. Each of them must be validated and error messages must be displayed, in a fashion similar to ActiveRecord forms: <%= form_tag %> <div class="fields"> <%= label_tag :friends_name %> <%= text_field_tag ...

Ruby On Rails ERB CSS Layout Question

I have a question with turning this html into erb. <button name="support" type="button" value="Get Support" class="brightOrange"> <span>Get Support</span> </button> I've been trying to do something like this in rails. <% form_tag get_support_path do %> <%= text_field_tag :email, "Email:" %> <% submit_tag "Join", :class=>"bri...

Rails 3 is "_method=PUT" still supposed to work?

I'm using FLEX 3 to make XML request to Rails 3. Since FLEX 3 only offers POST and GET, I have to use the "?_method=PUT" hack to maintain proper RESTfulness: http://127.0.0.1:3000/locator/locator_users/1.xml?_method=PUT On the server side its showing up as a POST and I'm getting an ActionController::RoutingError (No Route Matches). ...

Rails Associations (belongs_to, has_many) can't save 2 ids in table with a create method (user, post, comment)

Hi, Trying to write a basic "blog-like" app in rails 3, I'm stuck with associations. I need the create method save the post_id as well as the user_id in the comment table (which I need in order to retrive all comments written by a user in order to display it) The app has users (authentication - devise), posts (posted by users - but I'm...

Rails determine if objects from accepts_nested_attributes_for objects changed?

I am aware of the basic dirty indicator methods for rails, which work if direct attributes of an object have changed, I'm wondering how to determine if my children were updated.. I have a form for a collection of files, we'll call it a folder. A folder accepts_nested_attributes_for :files. What I need to determine (within the controller...

Rails ActiveRecord and array of primitive types

Hi guys, What is the best way to store array of of primitive types using Rails activerecord? For example I've got article model, which has images property. Images property is array of image urls. I don't wont use separate table to store this array. Regards, Alexey Zakharov ...

Pass options to find_or_create

Is is possible to pass options to a find_or_create method? I'd like to include a couple associations it the record is there. I though something like this would work but it's not including them. Event.find_or_create_by_asset_id(asset_id, :include => [:tags, :address]) ...

How do I save an object only after a delayed_job is successfully completed?

I have a delayed_job designed to send an email using a mailer. Upon completion, I need to record that the email was sent -- I do this by saving the newly created ContactEmail. Right now, the new ContactEmail records gets saved even if the delayed_job fails. How do I correct that so that the new ContactEmail is only saved when the mail...