ruby-on-rails

How do I cache a find in a controller using memcache?

I have this method in a controller: def article_info if @article = Article.find_by_permalink(params[:permalink]) @title = @article.title @description = @article.excerpt @body = @article.body else render_404 end end I ultimately want to cache the results of Article.find_by_permalink so that query isn't executed ev...

Opensocial Application... what to use on the server side?

I would like to create an opensocial application. I have read about how to do this on the client side, my question is what is the most appropriate server side technology to use? My idea requires persistent data and business logic that should be stored and executed on a server. I have some familiarity with creating full blown web apps in ...

State of Ruby on Rails Community and Framework

As an exercise I have spent the past 2 months learning Ruby on Rails. In learning RoR I relied heavily upon Agile Development with Rails. This book was an invaluable resource. From a learning perspective the 37Signals sponsored site Learn All About Ruby on Rails was also a great jumping off point. The issues that I ran into that were no...

RSpec: Expecting a message multiple times but with differing parameters

I currently have some expectations set up on a mock with consecutive calls: The spec: @my_mock = mock("a_mock") @options1 = {:some => "option"} @options2 = {:some_other => "option"} @first_param = mock("first_param") @my_mock.should_receive(:a_message).with(@first_param, @options1) @my_mock.should_receive(:a_message).with(@first_param...

Match string that ends with a given substring, except for certain cases, in Rails.

hi All, I have a regex /(.+)_id$/ in a rails application that matches any string that ends with _id . I need it to match any string that ends with _id except associated_id. How can I accomplish this? thx :) -C ...

problem with login page ruby on rails

Hi I'm following a tutorial: http://visionmasterdesigns.com/tutorial-create-a-login-system-in-ruby-on-rails/ to create a login page when I try to do this part: def authenticate 02. #User.new(params[:userform]) will create a new object of User, retrieve values from the form and store it variable @user. 03. @user = User.ne...

Database design strategy for a wine review site with top 10 lists and featured wines

I'm building a Wine review site and have run into a database design problem I was hoping someone could help me with. The basic premise of the site is that users will log in a leave reviews of wines they have tested. users wines reviews A user has many reviews, review belongs to user and review belongs to wine. This much is easy. ...

Referencing a SASS file from HAML

How do I reference a .sass file from a .haml file? I have the following haml expression that will reference a .css file: %link{'href' => '/stylesheets/layout.css?cache=1', 'rel' => 'stylesheet', 'type' => 'text/css'}/ How do I reference a .sass file? ...

rails redirect after create problem

Could anyone help with this problem: Upon "create", the user is redirected to the url: model/model_id (eg post/1), instead I am redirected to models/url_encoding_object (eg posts/.%23) and there is an "406 Not Acceptable" message in the console. Typically, upon create, the console's message is "Processing PostsController#create (for 00...

Rails category navigation with tags

Hi, rails newb here. I want to create a navigation system for my web application where there are several main categories for articles and several sub tags for each category. For example, in category "Writing" there might be subcategories like "Essays," "Poetry" and "Fiction." Each article would have a list of tags. If someone clicks t...

Find by attribute of has_many

Hi, I must throw my hands up and declare I'm completely stumped on this one! I have the following models: Chat: has_many :messages Message: belongs_to :chat, :counter_cache => true belongs_to :authorable, :polymorphic => true User: has_many :messages, :as => :authorable has_many :chats, :through => :messages, :uniq => true...

Missing template

Hi so i have this code: <% form_tag(:action => 'find') do%> Product name: <%= text_field("cars_", "name", :size => "30") %> <input type ="submit" value="Find"/> <%end%> upon pressing the button I want it to complete the method (def find) found in the controller but its requesting the html.erb file: Template is missing Miss...

Problem with form_for Helper

I have the following form_for declaration in a Rails site I am building: form_for(form_question, :url => { :controller => "form_questions", :action => "edit", :id => form_question.id }) do |f| but the site renders; <form action="/form_questions/1/edit"> why is it putting the '/1/' before the "edit" in the action url? ...

Best Rails / Android / Appcelearator development OS if have no money to buy a Mac

What operating system do you recommend. Currently I have Vista installed but it isn't developer friendly. I'm doing rails apps and learning Android development an Appcelerator. Oh, and haven't the budget for a Mac :( ...

Log files not being written to (Passenger)

Locally, my app runs fine on and writes to its logs. My production server is running CentOS with an Apache server running Passenger. When trying to debug, I noticed my log files were not being written to. First thing I did was chmod 0666 them, and when I found out that didn't work I looked at my apache log. I found this: Rails Error: Un...

Changing Index Page - Ruby on Rails

I am new to rails so go easy. I have developed my blog and deployed it successfully. The entire app is based out of the post_controller. I am wondering how I can reroute the users path to default to the post_controller vs. the app controller. To illustrate, if you go to http://mylifebattlecry.heroku.com you will see the default rails p...

Model Relationship Problem

I am trying to calculate the average (mean) rating for all entries within a category based on the following model associations ... class Entry < ActiveRecord::Base acts_as_rateable belongs_to :category ... end class Category < ActiveRecord::Base has_many :entry ... end class Rating < ActiveRecord::Base belongs_to :...

How to simulate the top site message bar that StackOverflow uses in Rails for the flash[:notice] and flash[:error] messages

I want to render my Rails flash[:notice] and flash[:error] messages in a bar at the top of the screen, similar to the message bar that StackOverflow uses when you get a new badge etc. Does anyone know how I can achieve this elegantly? Extra credit to make it slide in. ...

How do I add a method to a ruby gem without editing the gem source?

I am using the acts_as_taggable_on gem and would like to add a method to one of the gem source files (tag.rb), but I do not want to change the gem source in any way. I have tried creating my own tag.rb file to in the /app/models directory or in the /lib directory, and then adding the desired method to that file expecting that ruby will ...

Client-side autocomplete that matches with LIKE

Right now my autocomplete data lives on my server, which uses LIKE queries to find matches. Specifically, I'm taking the value of the "q" parameter, splitting it on whitespace, and looking for Songs that match every word: (using SearchLogic) @songs = Song.sortable_name_like_all(params[:q].to_s.split) Since I don't have many songs, I t...