ruby-on-rails

How can i parse Json with jquery

I need to parse a simple json response (from my rails app): [ { "photo": { "updated_at":"2010-10-14T19:12:35Z", "photo_file_size":206422, "created_at":"2010-10-14T19:12:01Z" } }, { "photo": { "updated_at":"...

Find how many yields and their names

Is there a way in Rails to find out how many yields have been defined in a layout along with their corresponding names? ...

how to automatically run bundle install if the gemfile is updated after a git pull/merge?

I imagine that I should write a git commit hook (post-merge?) that would look at the list of changed files and run bundle install if necessary after I fetch and merge from my git repo. But after some googling, I figure that either this should exist (couldn't find it!) or there's a good reason not to do this. Thoughts? ...

set fastcgi log location for rails app on shared host

I'm using a shared host to serve a rails app using fcgi. (Yes, it's old... passenger would be nice but it's not an option here.) Apparently fastcgi is logging errors to a serverwide log. I guess I need to close stdout/stderr and reopen them in my own location; how do I do this? Here's my dispatch.fcgi file. It claims that the log sh...

display image from file in temp uploaded directory

How can I display an image from file object? The file object holds the location of the image in temp uploaded directory. I dont want to use any models. Its for previewing a form having filefield ...

Multiple Layouts in Refinery CMS

Does anyone know how to make multiple layouts in refinery? It doesn't have to be in the user admin I just need to be able to programmatically tell some refinery pages to use one layout and others to use a different one. thanks. ...

ConnectionNotEstablished error when loading any page

I am getting this ConnectionNotEstablished error whenever I try to access any page on my rails app. The error only started to occur when I installed phpMyAdmin and changed my database's password. I updated my database.yml file to reflect the change but am still getting this error. Does anyone have more details about what this error is o...

Suggestions for next language to learn

I figured its time to start learning another language, but I can't decide between Ruby and Python (I'd like to start using Rails or Django). Which one do you think would be both most helpful and fun to learn, and if possible, could you give me some sites/links that would help me get started? If you think there's another language that wo...

Can a model belong_to more than one model ?

class Comment < ActiveRecord::Base belongs_to :post belongs_to :user end So with the above association can I fetch both user and post details from a given comment object?. like @comment.post.post_title and @comment.user.user_name. Also please note that I have used comment as a nested resource of post. resources ...

Testing redirect after login with Devise

I've followed the recommendation from the Devise github pages for this: http://github.com/plataformatec/devise/wiki/How-To:-Redirect-to-a-specific-page-on-successful-sign-in Now this works great, but how would you test that you have this behavior now? ...

RoR: Log SQL Queries in Production Log

Hi All, How can we enabled SQL query logging in production environment? Thanks, Imran ...

What are the most common ways of losing or having code overwritten when sharing a repository with another developer

What are the most common ways of losing or having overwritten code when sharing a repository with another developer? I say this after working with several share repos where magically a lot of my information disappears. What are some safe workarounds? I use Github. ...

Rails 3 model associations

I am making a simple BBS system with ruby on rails3. 3 main modesl are Members/Categories/Articles. Article belongs to Members/Categories, (member_id/category_id columns in db table) and each member/category 'has_many' articles. When a specific user tries to write an article, I tried it by def new @article = current_member.article...

image upload problem. Uploaded file size 0 bytes

I am trying to upload an Image. The image file gets created but the size of the file is 0 bytes. Here is the code in controller name = params[:comparison][:image1].original_filename name_content_type = params[:comparison][:image1].content_type directory = "public/images" path = File.join(directory, name) file = File.open(path, "wb") ...

Unnessary select Primary Key sequence calls

I recently switched to from using integer sequence IDs to UUIDs for primary keys in my rails 3 app using Postgresql, using a method similar to this method. As such, none of my tables have sequences, yet rails is still making (what I believe to be) unnecessary calls to select sequences when records are created. For example: PK and seria...

simple_form: how to create a grouped select box?

I'm using simple_form gem for creating Rails forms. http://github.com/plataformatec/simple_form All is great, except how do I create a grouped select box? Can't find it in the docs or by google-ing. ...

HTTP Post with Multiple Checkboxes (RoR)

I'm attempting to write a RoR controller that will post data to a page on behalf of a preexisting form. This form consists of a long list of checkboxes. I use a hash that represents the name => value pairs of the form elements. The problem is that all the checkboxes in the form use the same name but different value. I do not know how to...

Display 5 records per row?

Currently this just makes a long list. How do I display this with 5 records per row instead of 1? <% @tags.each do |tag| %> <p><%= tag_search(tag) %></p> <% end %> currently tag1 tag2 tag3 tag4 tag5 tag6 tag7 ... desired tag1 tag2 tag3 tag4 tag5 tag6 tag7 I know this is really basic but I just cannot manage to find the right ...

Connection Issue while using Jasmine Javascript Testing Framework

I am having an issue using Jasmine on Ubuntu when trying to run the example javascript specs through Selenium using the "rake jasmine:ci" command. I will periodically get a "Connection refused" error when net/http is trying to connect to the port where Selenium is running. An example the start of the backtrace I get is: Waiting for jasm...

What is the best way to do comet/long polling in rails?

Either existing libraries or a discussion of how to implement it would be fine. I'm trying to find a solution that doesn't require thread blocking. I've found some solutions (like juggernaut and orbited) and was wondering what else was out there. ...