ruby-on-rails

Is there a better acts_as_commentable for Rails?

Here's what I'm looking to do. I have a site where I want the user to be able to leave comments on various Models. acts_as_commentable is the obvious starting point for this, but I'm curious if there is a gem / plug-in with a more robust feature-set. For example: Pre-built partial(s) (w/ or w/o Twitter / FB buttons) Partial(s) that uti...

Multiple HTTP request - Rails

My application checks a number of domains to see if they are valid (approx 100). I have the following code to check a single domain: def self.test_url uri, limit = 10 if limit == 0 return get_error_messages("001") end begin url = URI.parse(uri) response = Net::HTTP.start(url.host, url.port).request_...

Rails Plugin - Install as Plugin or Install As Gem

Hey guys, I am new to rails and have a question regarding the plugins. It seems there are two approaches you can take when using a third party plugin in a ROR App: 1) install a gem using sudo gem install GEM, and then "require" it in your rails project 2) install the plugin using script/generate plugin install PLUGIN. The plugin in c...

FckEditor in Rails: textarea problem + ID

Hey all, I'm using the FCKEditor in my Rails app and everything works as it should except for ... 1] When putting a textarea into the fckEditor, saving it and going back to the page, everything after the textarea is posted below the FCKEditor as plain HTML code. So when I resave, everything after the (first) textarea is lost. Anyone ever...

Checking if ActiveRecord find returns a result

I'm trying to check if a find method returns a result. My find method is the following: post = Post.find(:all, :conditions => { :url => params['url'] }, :limit => 1) What would be a good way to check that post contains a result? ...

Ordering .each results in the view...

I am wondering if it is possible to dictate the order (i.e. :order => 'created_at DESC') within the view. I realize that logic in the view is not ideal but I seem to be having some problems locating where to affect this output. For instance, here is my code: <% @user.questions.each do |question| %> <%= link_to_unless_current h (ques...

Docs for auto-generated methods in Ruby on Rails

Rails has all sorts of auto-generated methods that I've often times struggled to find documentation for. For example, in routes.rb, if I have: map.resources :projects do |p| p.resources :tasks end This will get a plethora of auto-generate path and url helpers. Where can I find documentation for how to work with these paths? I gener...

Authlogic OpenID integration

I'm having difficulty getting OpenId authentication working with Authlogic. It appears that the problem arose with changes to the open_id_authentication plugin. From what I've read so far, one needs to switch from using gems to using plugins. Here's what I done thus far to get Authlogic-OpenID integration working: Removed relevant g...

Rails Plugin or Gem for User - Group Management

I'm looking for something a bit different than regular app authorization; I need a tool for managing user authorization against resources related to generic projects or items, similar to what Backpack does with page participation. For example, there is a pool of users, and when an admin creates a new project (or, more generically, "item ...

Error happening when running "rake db:create RAILS_ENV='development' "

Hi, I am getting this error in my terminal when i execute the command above, Deans-MacBook:depot dean$ rake db:create RAILS_ENV='development' (in /Users/dean/src/RailsBook/depot) Couldn't create database for {"username"=>"root", "adapter"=>"mysql", "database"=>"depot_development", "host"=>"localhost", "password"=>nil}, charset: utf8, ...

How do I add and remove multiple "belongs_to" instances to and from a "has_many" instance?

I currently have two models: Campaigns and Videos. Videos belongs to Campaigns and a Campaign has many Videos. In my Campaign form I want to be able to add Videos that have no parent and also be able to remove Videos that belong to the selected campaign. I came up with using two separate multiple selection lists for this. One list has al...

test_case files in rails components

I noticed there are a bunch of test_case.rb files delivered in the rails components: ./actionmailer-2.3.5/lib/action_mailer/test_case.rb ./actionpack-2.3.5/lib/action_controller/test_case.rb ./actionpack-2.3.5/lib/action_view/test_case.rb ./activerecord-2.3.5/lib/active_record/test_case.rb ./activesupport-2.3.5/lib/active_support/test...

Rails: Using will_paginate with a complex association find

I'm encountering a problem with will_paginate while doing a complex find. :photo has_many :tags, :through => :tagships :item has_many :photos :photo belongs_to :item @photos = @item.photos.paginate :page => params[:page], :per_page => 200, :conditions => [ 'tags...

How do I convert a Twitter User ID to a Twitter Username

I'm building an app in Rails that needs to convert a Twitter ID into the Twitter username. This is the code that pulls the ID. url = 'http://twitter.com/' + params[:username] buffer = open(url, 'UserAgent' => 'irb').read @vouched_user_twitter_id = buffer[/\d+(?=\.rss)/] How do I use that number to pull the username once I no longer ha...

Twitter Oauth Strategy with Warden + Devise Authentication Gems for Ruby

Devise, the authentication gem for Ruby based on Warden (another auth gem) does not support Twitter Oauth as an authentication strategy, BUT Warden does. There is a way to use the Warden Twitter Oauth strategy within Devise, but I cannot figure it out. I'm using the following block in the devise config file: config.warden do |manager...

Rails plugin for generating dynamic / ajax crud interfaces compatible with Rails 3 beta?

Anyone know of some good gems or plugins to create dynamic / ajax crud interfaces for Rails 3 projects? I know active scaffold was popular before and it's been awhile since I have used it / any other gems similar to this (I usually just write it myself). I like the direction that the formtastic gem (http://github.com/justinfrench/formta...

mongoid, set_table_name & attr_accessible

Hi! I'm using rails3 edge and mongoid 2beta6 with ruby 1.9.2-head. How can I manually change the table name, just like set_table_name for ActiveRecord? For example my model Signup should use the table "users" for storage, not "signups". Another question is how to implement the bevahior of attr_accessible AR provides? Thanks, Corin ...

Ruby libraries for parsing .doc files?

Hi all, I was just wondering if anyone knew of any good libraries for parsing .doc files (and similar formats, like .odt) to extract text, yet also keep formatting information where possible for display on a website. Capability of doing similarly for PDFs would be a bonus, but I'm not looking as much for that. This is for a Rails proj...

How do I create a reply button for a Twitter client that automatically fills in a username in the 'tweet' form?

Using the Twitter API, and just want to have a simple 'reply' button on every tweet (say, 'How do I create a reply button?' from @kraykray) that automatically puts '@kraykray' into the tweet form. Don't need the system to log that it's any kind of special message. ...

Ruby (and Rails) nested module syntax

I'm wondering what the difference is between the following two modules # First Example module Parent module Child end end and # Second Example module Parent::Child end Using the 2nd method, it appears as though the Parent module must be previously defined, otherwise I get an 'uninitialized constant' error Given this, what is t...