When you run:
rake db:migrate
the only files that are being processed are those in db/migrate/ right?
Well since relationships such as one-to-one, one-to-many and many-to-many are defined in the in app/models/ , how does Rails enforce such relationships? After I do my migration and look at the generated database schema, I can't see a...
For example, let's say I have a Question model, that has the boolean fields answered and closed. How would I test the behavior that a Question should be read only when marked as answered using RSpec? This seems like it's the behavior of the model, but I'm not sure how to best test it. Should I be using a before filter for this behavio...
Yet another argument with a friend of mine. Consider this code:
class User < ActiveRecord::Base
has_many :groups
def in_group?(group)
groups.include?(group)
end
end
class Group < ActiveRecord::Base
has_many :members
def add_user(user)
members << user
end
end
My opinion is that these methods add extra unnecessar...
I am learning Ruby on Rails so I'm sure I'll find this out sooner or later.
Why would the scaffold method be deprecated in version 2 of Rails?
...
In a Rails app sometimes you use a redirect in an action...
redirect_to :controller => 'sessions', :action => 'new'
I wonder if that's bad though because it sends back a 302 status to the browser and then the browser makes a whole new request. It's an additional back-and-forth.
Would it be better to just render a template?
render :t...
Hi All,
I have a rails app and a separate druby process. This process gives me some methods, and at the first line of each druby's method there is a call to ActiveRecord::Base.establish_connection, where the db_name depends on a param set by the rails application.
Sometimes the process is getting the wrong database name and I think it ...
I have Subversion setup and running on my local network with windows and svnserve. I'd like to use Capistrano to deploy to a remote ubuntu server but am a bit on unsure on what I need to do to get the client end to work on windows. My understanding is that the remote server needs to be able to tunnel into my subversion server. I've re...
I have a select box that looks like this (within a form_for)
<%=f.select(:whatever_id, {"blah"=>0, "blah2"=>1, "blah3"=>2, "blah4"=>3}, {:include_blank => true}) %>
and the output is good, but weird... like this:
<select id="personal_information_whatever_id" name="personal_information[whatever_id]"><option value=""></option>
<optio...
I'm getting a failing test here that I'm having trouble understanding. I'm using Test::Unit with Shoulda enhancement. Action in users_controller.rb I'm trying to test...
def create
unless params[:user][:email] =~ / specific regex needed for this app /i
# ...
render :template => 'sessions/new'
end
end
Test...
context 'on...
Due to hosting constraints I am porting an ASP.NET MVC to Ruby On Rails. In my ASP.NET application I had 2 web applications. One for the Admin section, and one for the public section.
Both referenced a class library that held all my Business Logic and Data.
Now I want to accomplish the same thing in Ruby On Rails. How do I use my mod...
I have a Ruby script in my Rails app that I use to load some data from Twitter.
In the future I will make it an automatic background process, but for now I run it manually like:
ruby /lib/twitter/twitterLoad.rb
In order to use the Rails model classes and such, I have the following as the top line of the script:
require "#{File.dirn...
Working with Test::Unit and Shoulda. Trying to test Users.create. My understanding is that Rails forms send params for an object like this:
user[email]
Which turns into hash in your action, right?
params[:user][:email]
OK, so in my test I've tried...
setup { post :create, :post => { 'user[email]' => 'invalid@abc' } }
and
setup ...
I've just installed the OpenID Authentication plugin because I'd like to use it for my projects, but as I tried to login using my blog url I got the first error message:
"Sorry, the OpenID server couldn't be found"
Does the plugin support delegation?
If yes, what is wrong with my blog? (I use wp-openid with XRDS-Simple)
Thanks!
...
I have the following Rails link generating code
(I have removed potentially 'industry secret' stuff, sorry for the odd names, but the length of variable names and values match)
<%= link_to_remote "FOUR", :method => "get", :url => {:action => "testing01_four_log_info", :fourth_name => "LA1", :testing01_num => "123"} %>
This code gener...
What is the correct syntax for sending an email with actionmailer that includes some PDF file attachments? I am using Gmail for SMTP, with the TLS plugin. Here is what I have so far (and have tried variations on this too):
**lead_mailer.rb:**
def auto_response(lead)
recipients lead.email
subject "Information"
body ...
I'm having some performances issues in a rails project (running on rails 2.0.5), for example in my user administration pages.
my user model has many relations (details, addresses, roles...) who get loaded with eager loading. That creates really huge SQL queries, for some cases, it takes almost a minute to load 30 users. On the other han...
Let's say that in the controller I get an array of objects from the database this way:
@statuses = TwitterStatus.find(:all, :order => "tweet_id DESC", :include => :twitter_user)
Also I have the following loop in the view:
<% unless @statuses.nil? -%>
<ol>
<% for status in @statuses %>
<li><%= h(status.text -%>/li>
<% end -%>
</ol...
I have a large database of users (~200,000) that I'm transferring from a ASP.NET application to a Ruby on Rails application. I don't really want to ask every user to reset their password and so I'm trying to re-implement the C# password hashing function in Ruby.
The old function is this:
public string EncodePassword(string pass, strin...
I'm working on a rails app.
I have a dropdown with countries. Selecting a country would fill the city dropdown with the cities in that country.
I know how to do this server-side, but I'd like to do it client-side if possible. I've used the RJS helpers, but I've no experience with jQuery (not exactly even sure what it is) or the other...
I have a User.create action that provisionally registers a new user and sends an email with a generated password. What is the most Rails-like way to complete that action? I want to do everything exactly right from now on. No more nonsense. This time I'm serious.
I'm thinking these are the options...
Create a view called login_email_se...