ruby-on-rails

Ruby on Rails Blog

Does anybody know a basic plugin/gem that will allow me to quickly set up a blog in Rails. I would like it to have a WYSIWYG editor that allows image upload and basic editing. All the Google results I checked out were tutorials to creating a blog in Rails. I'm not looking to roll out my own solution, I'm looking for something that was ...

How do you scope ActiveRecord associations in Rails 3?

I have a Rails 3 project. With Rails 3 came Arel and the ability to reuse one scope to build another. I am wondering if there is a way to use scopes when defining a relationship (e.g. a "has_many"). I have records which have permission columns. I would like to build a default_scope that takes my permission columns into consideratio...

How to monkey patch a rake task shipped with Rails?

I just found a bug in one of the rake tasks shipped with Rails. Is there a way to monkey patch a rake task? ...

Rails helper methods

I'm doing some refactoring on a piece of code I have, and am thinking of moving some stuff from the model into helper methods. Nothing major, but my model does some screen-scrapping, and I need to treat (and filter) some of the strings returned, so they are passed back to the controller nicely formatted. I've been using helper methods ...

Rails page caching with intra-page administration

I'd love to use page caching on a Rails site I run. The information on each page is mostly constant, but the queries that need to be run to collect the information are complicated and can be slow in some cases.The only obstacle to using page caching is that the administrative interface is built into the main site so that admin operations...

Should I use multiple databases?

I am about to create an application with Ruby on Rails and I would like to use multiple databases, basically is an accounting app that will have multiple companies for each user. I would like to create a database for each company I found this post http://programmerassist.com/article/302 But I would like to read more thoughts about this ...

how i can select those records in which same row and in same column value is repeated

like i have a file with attributes or columns fullname, addressln1, city, state, zip and someone just mass up that files and in some records fullname column name come up like "joe joe David" or "syed hashim Ali syed" i just want to select those records and take out from file to fix them can i do that in sql or excell please please help m...

Fixing form action when using iUI and Rails

Run into a bit of a problem when submitting a Rails form while using iUI. When submitting a form using the form_for helper in Rails, it jumps to a new separate page and loses it's original formatting. This is a problem for iUI which uses some fancy javascript/css etc to give the web app a nice native iPhone feel. Anyone got any ideas? ...

2 Rails Apps, 1 Database (using Heroku)

I've made 2 apps, App A and App B. App A's sole purpose is to allow users to sign up and App B's purpose is to take select users from App A email them. Since App A & B were created independently & are hosted in 2 separate Heroku instances, how can App B access the users database in App A? Is there a way to push certain relevant rows from...

Ruby on Rails: Best way to tie together two models that correspond one to one

If I have two models that are guaranteed to have a one-to-one correspondence, i.e. if one is created, I will always also need the other, and if one is deleted, I will also want to get rid of the other, what's the best way to tie them together? I see that the has_one/belongs_to :dependent method takes care of the deletions, but I don't s...

Properly handling unicode characters in Rails

By default Rails allows users of our application to input non-utf8 data, such as: ¶®«¼ However when we attempt to retrieve the data from our database and render it in a template Rails incorrectly assumes that it is in UTF-8 format and throws an error. ArgumentError: invalid byte sequence in UTF-8 What is the best way to handle this? ...

Help with database strategy for giving roles to users in specific model instances

I have a ruby app running with declarative authorization and I have made the roles: admin ( app admin ) org_admin ( organization administratr ) org_colab ( organization colaborator ) org_visitor ( organization visitor ) a User can has_many Organizations and he can be an admin or a colaborator. I link them using a Affilia...

MongoMapper find EmbeddedDocument

Hi, I'm a little stuck with the concept of EmbeddedDocuments in MongoMapper. My Models look like this: class Post include MongoMapper::Document many :categories many :qualities end class Category include MongoMapper::EmbeddedDocument belongs_to :post many :qualities end class Quality include MongoMapper::EmbeddedDocume...

How can I see what capybara found in a failing cucumber step?

I started migrating from cucumber + webrat to cucumber + capybara. Now the behavior of "I should see " seems to be somewhat different. Most of these fail now, although I didn't change anything on the page. I replaced the snippet that should be found with some stuff that is on every page and for some text it works and for other text it do...

Rails PayPal proof of concept

I'm trying to create an ultra simple paypal custom integration with rails. I'm following Ryan Bates Railscast #141 on this subject and I've simplified it even further. If you have experience with super simple paypal integration, any advice would be appreciated! I'm attempting to pass everything through my account model. A proof-of-conce...

Rails ActionCaching with Memcached fragment hit but action gets called anyway

Hi stackoverflow. I'm running into something strange. I'm using memcached with a caches_action setup. I'm doing this in 4 different controllers. In two of them, it works flawlessly (so far), though admittedly those two controllers are less complicated than the two in which it doesn't seem to work. I'm doing something like this: cac...

Rails: MIME type issues with .m4v files

In my Rails app I'm trying to get the MIME type of a file like so: MIME::Types.type_for("example.m4v").to_s But it's not recognizing it. I tried adding the following to config/initializers/mime_types.rb (and restarted the server) without any luck: Mime::Type.register "video/mp4", :m4v ...

Will defunct processes prevent proper running of other processes?

My mongrels were not responding, and neither god restart nor cluster restart made a big difference. I dug a little deeper, than i realized that i had plenty of zombie processes. app 29607 27948 0 19:45 ? 00:00:00 [mongrel_rails] app 30578 21681 0 19:52 ? 00:00:00 [mongrel_rails] app 30704 21405 0 19:53 ...

Ruby: call list of methods until one returns true

Is there a pretty way to make a series of method calls in ruby UNTIL one returns true? This was my first thought, but was thinking there might be a nicer way: if method_one elsif method_two elsif method_three else puts "none worked" end ...

Handling cookies with Flex for Authentication

Hi, I'm using Flex 4(beta2) with Ruby on Rails 2.3.5 and using RubyAMF to transfer data back and forth between Flex and server. I set up Authlogic on the Rails side for authentication. I wasn't sure what's the best method to handle user sessions. I know this is done automatically with Rails by sending session id with cookie which Rail...