Hi guys,
I known that it's more a state of art than a technical question, but I'm looking for some good templates to document model relation, validations, method for the models and controllers of my rails app.
Are there any conventions/best practice/examples to do that ?
Thanks all for your help
...
Rails routes are great for matching RESTful style '/' separated bits of a URL, but can I match query parameters in a map.connect config. I want different controllers/actions to be invoked depending on the presence of a parameter after the '?'.
I was trying something like this...
map.connect "api/my/path?apple=:applecode", :controll...
I've been reading all kinds of tutorials on how to deploy rails apps on heroku from windows.
I've tried installing git, heroku gem, generating ssh keys and setting paths and everything...
I get either public key error (without putty) or fatal no auth found (with putty)...
...
I have the following controller test case:
def test_showplain
Cleaner.expect(:parse).with(@somecontent)
Cleaner.any_instance.stubs(:plainversion).returns(@returnvalue)
post :showplain, {:content => @somecontent}
end
This works fine, except that I want the "stubs(:plainversion)" to be an "expects(:plainversion)".
Here's the co...
I have a page with brands, tags, comments and products. It's time to go international
and I have some question about how to setup the I18n.
I have read some about Internalization and even tried the globalize gem
1 year ago but it's still lot of things I don't know how do handle.
I translate the static text on my webpage using the beauti...
I had a terrible morning. Lots of emails floating around about why things don't work. Upon investigating I found that there is a data mismatch which is causing errors.
Scenario
Customer and Address are two tables.
Customer contains
class Customer < ActiveRecord::Base
has_one :address, :foreign_key => "id"
end
Address...
I have a drop down list of Type in my Products model.
I want to be able to search in the Products index.html.erb so a user selects a type from a drop down list, clicks search and all the products matching that type are returned.
I can get normal search methods working where the user enters in their search in a text box but I cannot get ...
This are my models:
class Speaker < ActiveRecord::Base
belongs_to :session, :foreign_key => :session_id, :class_name => :Session
belongs_to :speakable, :polymorphic => true
end
class Session < ActiveRecord::Base
has_many :speakers
accepts_nested_attributes_for :speakers
end
class Person < ActiveRecord::Base
has_many :speak...
Hi,
I am working with vestal version for 2 months. Everything was fine until this afternoon.
I didn't done anything special(or i don't remembered...) but the code works fine on others computers...
The problem is that i'm not able to save my model anymore: rails give me this error : ActiveRecord::DangerousAttributeError: changes is de...
What I'm trying to do is make a basic flashcard app on rails. At this point, all I'm looking for is the functionality to iterate through a list of flashcards, quiz the user and let the user know if they were right or not. In ruby, it didn't take me long to write:
class Card
attr_accessor :answer, :question
def initialize(answer = ...
Hi everybody... I've been thinking about this a long time now but I want to hear your opinion because I always receive the best answers here. So any advance... thank you guys.
Right now I have to make this decision:
Shift a prototype webservice to production quality. Choose either Ruby or PHP...
(Background: A friend of mine is joinin...
<% form_for :user, @user, :url => users_path(:from => 'landing'), :id => 'sign_up_form', :html => {:method => :create} do |f| -%>
Can someone tell me why the ID isn't working?
...
Please bear with me for a moment as I try to explain exactly what I would like to achieve.
In my Ruby on Rails application I have a model called Page.
It represents a web page.
I would like to enable the user to arbitrarily attach components to the page. Some examples of "components" would be Picture, PictureCollection, Video, VideoC...
Let's say I have:
class ForumTopic < ActiveRecord::Base
has_many :forum_posts
named_scope :number_of_posts, ??????
end
class ForumPost < ActiveRecord::Base
belongs_to :forum_topic
end
What should I put in ????? to allow searchlogic query like:
ForumTopic.descend_by_number_of_posts
Any help would be very greatly appreciated!
...
Feel pretty dumb with this question.
In a Rails Model, I want to be able to find out the host and protocol. For example, if I am in a test environment it would return http://localhost:3000/ and if I was in production it would return something like http://my.application.com/?
Is this even possible?
Thanks!
jt
...
Hi, I'm new to rails and I'm trying to make a help page that just lists questions and answers. Currently I have something very simple like this :
<% @helps.each do |help| %>
<%=h help.category %>
<%=h help.question %>
<%=h help.answer %>
<% end %>
Along with each question and answer is a category they belong to. How do i create a drop...
I am implementing a betting system and each user has a balance , how can i find a rank of a user using activerecord methods?
thanks for your help.
...
I'm running on WinXP + Ruby 1.8.6 + Rails 2.3.5 (frozen to the project) in development environment.
Looking at development.log I observe inconsistent data as to the time spent on a database stuff.
Example #1 (good):
Processing PagesController#index (for 127.0.0.1 at 2010-05-11 12:15:54) [GET]
Parameters: {"action"=>"index", "controlle...
I'm running into a little hiccup with my AJAX creation of comments for posts. Everything works great but I am doing this in the index.html.erb view so the create.js.erb is finding the first div that says "comments" and inserting the comment there.
I know how to create a post specific div by using:
<div id="comments_<%= post.id %>
B...
I'm try to write a spec for a named scope which is date dependent.
The spec:
it "should return 6 months of documents" do
Date.stub!(:today).and_return(Date.new(2005, 03, 03))
doc_1 = Factory.create(:document, :date => '2005-01-01')
Document.past_six_months.should == [doc_1]
end
The named scope in the Document model:
name...