Hey,
where would I place additions to stdlib classes in a rails project? Let's say something like:
class Date
def foo
'foo'
end
end
I thought about the initializer folder but it somehow felt wrong. Ideas?
...
I'd like to run an app in a restricted private beta on heroku.
We're changing the app regularly and haven't done a security audit.
To stop anyone exploiting stuff, we'd like to lock down the whole site, so you need a password to access anything.
Ideally similar to using .htaccess and .htpasswd files to lock an entire site on an Apache...
Hello I want to create seo optimize url in rails.Same like done in stackoverflow.
Right now this is my url
http://localhost:3000/questions/56
I want to make it something like this:-
http://localhost:3000/questions/56/this-is-my-optimized-url
i am using restful approach.
is there any plug-in available for this.
...
Hi,
I'm trying to rename the authlogic error messages in a Rails 3 app.
The general format I found out working in Rails 3:
de:
errors:
template:
header:
one: "Konnte {{model}} nicht speichern: ein Fehler."
other: "Konnte {{model}} nicht speichern: {{count}} Fehler."
body: "Bitte überprüfen Sie die...
In my every model i have 10 or more lines for self.errors.add_to_base. is there any other way i can manage those lines in more easy way? will it possible to manage those errors with some common function which can handle self.errors.add_to_base for any of my model?
Function like
def error_add_to_base(message,conditions)
self.errors...
I'm using rspec and cucumber for BBD.
Now I'm migrating to rails 3 and rspec 2 and as I could see both of frameworks (shoulda and remarkable) support rails 3 and rspec 2.
I have never used shoulda or remarkable.
What should I prefer to use with rspec: shoulda or remarkable? And why?
...
if ClassName.exists?(["id = ?", self.id])
object = ClassName.find_by_name(self.name)
object.update_attributes!( :street_address => self.street_address,
:city_name => self.city_name,
:name => self.org_unit_name,
:state_prov_id => self.state_prov_id,
:zip_code => self.zip_code)
else
ClassName.create! :street_address =...
Guys,
I'm having trouble understanding why I can't seem to stub this controller method :load_user, since all of my tests fail if I change the actual implementation of :load_user to not return and instance of @user.
Can anybody see why my stub (controller.stub!(:load_user).and_return(@user)) seems to fail to actually get called when ...
I am developing my application using Rails. It has 400 or more models and some models contain more than 200 rows just for relationships, so it's too hard handle it. Are there any ways I can handle my application in more proper and easy ways?
...
I've been working on a log viewer for a Rails app and have found that I need to read around 200 lines of a log file from bottom to top instead of the default top to bottom.
Log files can get quite large, so I've already tried and ruled out the IO.readlines("log_file.log")[-200..-1] method.
Are there any other ways to go about reading a...
Right now I'm building a project management app in rails, here is some background info:
Right now i have 2 models, one is User and the other one is Client. Clients and Users have a one-to-one relationship (client -> has_one and user -> belongs_to which means that the foreign key it's in the users table)
So what I'm trying to do it's on...
I just installed Rails 3 and created my first app. The install of Rails3 + ruby 1.9 went very smoothly but I am missing the generate script in script/generate.
I have created a new app from scratch with no options to verify.
Any idea why this is happening and how to fix it?
...
Since 'HTML' do not have the attribute 'name',I am looking for a way to accept the value, which I populated in views, in the controller and assign it a variable name for another use.
This is sample of my code:`
enter code here<form action="<%=url_for(:action =>:make_comment) %>">
<fieldset>
<select>
<%@category.each {|x|%>
<option id="...
This is a very common piece of code
<% form_for :blah... do |f| %>
<%= f.error_messages %>
First name: <%= f.text_field :first_name %><br />
....
<% end %>
error_messages is a helper method but I am having a hard time finding the documentation for it, why is that?
...
What's the best way to test scopes in Rails 3. In rails 2, I would do something like:
Rspec:
it 'should have a top_level scope' do
Category.top_level.proxy_options.should == {:conditions => {:parent_id => nil}}
end
This fails in rails 3 with a "undefined method `proxy_options' for []:ActiveRecord::Relation" error.
How are peopl...
I'm using Rails 2.
I have resources nested like this:
- university_categories
- universities
- studies
- professors
- comments
I wish to use RESTful routes, but I don't want all that clutter in my URL. For example instead of:
/universities/:university_id/studies/:study_id/professors/:professor_id
I want:
/professors/...
I have an article model and an category model. Category act as tree.
What is the best approch to build a select list to allow the administrator to select an category from a select list to associate it later with an article ?
semantic_form_for(@article) do |f|
f.input :title, :as => :string
f.input :content, :as => :text
f.input :...
I have a model, Card, with multiple subclasses through single table inheritance. I have another model, CardSet, with multiple subclasses through single table inheritance. Cards have many CardSets, and CardSets have many Cards, both through Memberships.
Given that a class FooCard is a subclass of Card, and class FooSet is a subclass of...
I have opened this as an issue on Github (http://github.com/thoughtbot/paperclip/issues/issue/225) but on the chance that I'm just doing this wrong, I thought I'd also ask about it here. If someone can tell me where I'm going wrong, I can close the issue and save the Paperclip guys some trouble.
Issue:
When using S3 for storage, and y...
Do I have to create a new instance of the join table and set the values or can I say something like
student.classes.add(class) and that will work?
Sincerely,
tesmar
...