ruby-on-rails

proper permissions for a rails app

Nginx is giving me a 403 Forbidden error. It looks like my permissions are wrong. This is what I have going on my local machine: drwx------ 13 sean sean 4096 2010-07-10 13:17 . drwxr-xr-x 41 sean sean 4096 2010-07-13 17:55 .. drwx------ 6 sean sean 4096 2010-07-09 16:45 app drwx------ 5 sean sean 4096 2010-07-13 17:54 co...

English list...

I have a scenario where I need to supply users a message. The message can be in the following forms: "John likes to eat < b>squirrel< /b>." "John likes to eat < b>squirrel< /b> and < b>gator< /b>." "John likes to eat < b>squirrel< /b>, < b>gator< /b> and < b>birdpoop< /b>." "John likes to eat < b>squirrel< /b>, < b>gator< /b>, < b>bir...

How to install a git plugin on Rails 3

Hey everyone, I'm completely new to Rails and just installed Rails 3 on Ubuntu 10.04. I was wondering if someone could please explain how to install a plugin from a Git repository. More specifically, I'm trying to install the restful-authentication plugin from the git repository: git://github.com/technoweenie/restful-authentication.git...

"Crawl" a page / site for keywords

Last year I dabbed in a bit of perl programming. The first thing I wrote was a simple script that took a web page and found out how many times a word or name was on that page. I refer to this as "crawling" is that correct?. I was wondering If this is a native process for other languages like PHP and ROR. Essentially I want to build my ow...

before_create - destroying multiple records

Ok, I am trying to destroy multiple records in a before_create: class InventoryItem < ActiveRecord::Base belongs_to :user belongs_to :item before_create :replace_owned_items protected def replace_owned_items user = self.user item = self.item owned_items = user.retrieve_owned_items(item) unless owned_items.b...

Rails 2 options_for_select with an ActiveRecord resultset

Does anyone know a better way of displaying the contents of an activerecord result set as a select box. I would like todo this @users = User.all <%= f.select_box :users, options_for_select(@users) %> But for now I need to parse all the users into a multidimensional array with a sub array [username,user_id] Any ideas? ...

In Rails how does one find disassociated records in a HABTM relationship?

I have a HABTM relationship between Videos and Campaigns in Rails which means the association is stored in a join table. I want to find all the Videos that do NOT have an associated campaign. What would be the most efficient way of doing this? Thank you for looking =) ...

How to preserve quotes in a Rails form submission?

How does one preserve the original quotes? The quotes are required when submitting a quoted search string, for example. Search form example1: ruby "new york" Search from example2: "new york" Resulting params[:q]: for example1: "ruby \"new york\"" for example2: "new york" Note that Rails throws away quotes if the entire string i...

Android app syncing with remote service

Hi, is there any possibility to sync local database on android device (sqlite) and remote database over the air? For example - to sync tasks between device and web application. ...

Rails link_to_remote rendering nothing, why?

RoR newbie here. Working the "play time" exercises at the end of Agile Web Dev with Rails, chapter 9. Can't get link_to_remote to generate a link for me in a partial. My store_cart_item.html.erb partial looks like this: <% if cart_item == @current_item then %> <tr id="current_item"> <% else %> <tr> <% end %> <td> <!-- stuck her...

How do I write a named scope to filter by all of an array passed in, and not just by matching one element (using IN)

I have two models, Project and Category, which have a many-to-many relationship between them. The Project model is very simple: class Project < ActiveRecord::Base has_and_belongs_to_many :categories scope :in_categories, lambda { |categories| joins(:categories). where("categories.id in (?)", categories.collect(&:to_i)) } ...

How to count the object number instead of getting all object in Ruby?

For Example, I want to know the User have how many post. So, I do it in this way; user.posts.length It works, but when I see the server log, it shows me that: SELECT * FROM "posts" WHERE ("posts".user_id = 6) actually, I need to know the post number only, how can I do this? Thank you. ...

Does anyone know of an iPaper alternative?

We would like to display office documents in the browser (DOC, PPT, XLS and PDFs). The iPaper API from Scribd is perfect but ideally it would be installed on our server. Open source is a preference but commercial is ok. Looking for an easy, server side, good looking, minimal interface flash frontend viewer. Thanks! ...

How to map more than one Attribute with ActiveRecord?

Hi Guys, quick question. If I type in my console u = User.first u.friends(&map:username) I geht ["Peter", "Mary", "Jane"] But I also want to show the birthday, so how do I do that? u.friends(&map:username, &map:birthday) doesn't work thanks in advance ...

which acts_as_taggable

There are multiple plugins available for tagging in a rails app. Which one would you suggest. What are the pros and cons. Thanks Pankaj ...

RoR trim string

Hi <%= user.name[0..9] %> this gives abcdefghi but I want it to be if length is greater than 5 then abcde... if less than 5 then abcde ...

How to get complete production.log from a rails app in heroku?

Hi folks, I wanted to have a detailed look into my production.log, but heroku doesn't seem to store them. Does anyone else, have a solution for that problem. It would be nice to get it stored safely away. thanks in advance :) ...

Tracking changes on instances of a class and their associations - thoughts?

Hi all. I have a class Question which has a lot of assocated models. On one page on my app i list a summary of all the current questions, with various info from associated records. Ultimately this is a hash of values that i then just print out into a csv-style row (i'll call this the 'row hash' from hereon) I now have a requirement t...

collection_select doesn't let ActiveRecord update its collection when none of options is selected.

I have has_and_belongs_to_many association between two models. I made use of collection_select to represent the other model in this association in a form. When I tried to deselect options in collection_select, collection_select doesn't post its empty value and, thus, it doesn't let ActiveRecord pass any update clause to the database. ...

LEFT OUTER joins in Rails 3

I have the following code: @posts = Post.joins(:user).joins(:blog).select which is meant to find all posts and return them and the associated users and blogs. However, users are optional which means that the INNER JOIN that :joins generates is not returning lots of records. How do I use this to generate a LEFT OUTER join instead? ...