Suppose I have three models: Student, SchoolClass, and DayOfWeek. There is a HABTM relationship between Student and SchoolClass, and between SchoolClass and DayOfWeek. What I'd like to do is find all school classes belonging to a given student that meet on Monday.
Now I suppose I could do something like:
@student = Student.find(:studen...
I need some help in fixing the below issue.
I had transaction blocks in my rails code like below:
@sqlcontact = "INSERT INTO contacts (id,\"cid\", \"hphone\", mphone, provider, cemail, email, sms , mail, phone) VALUES ('"+@id1+"','" + @id1 + "', '"+ params[:hphone] + "', '"+params[:mphone]+ "', '" + params[:provider] + "', '" + param...
I have a table already created. I am looking for a rails migration where I can modify the starting point of the auto_increment number for id column of my table. Let's say I want it to start from 1000.
I googled a bit and came across this:
it says:
:options "string" pass raw options to
your underlying database, e.g.
aut...
Hi,
I have built a small text based search engine on ROR which will display relevant records having a specified search word in it.since few of the records has more than 1000 words i have truncated each result set to 200 characters.My views file search.html.erb looks like this
<% @results_with_ranks.each do |result| -%>
<% content_id...
what would happen if both actions have some template to render?
...
I'm creating a Ruby on Rails application, and I'm trying to create/login/logout users.
This is the schema for Users:
create_table "users", :force => true do |t|
t.string "first_name"
t.string "last_name"
t.text "reputation"
t.integer "questions_asked"
t.integer "answers_given"
t.string "request"
...
I'm not sure I understand the difference between the html.erb files and erb files in the views for a Ruby on Rails application. (Similarly for haml files.)
What are the dis/advantages of each (html.erb/haml or erb/haml) files?
PS I'm not asking about the difference between the erb and haml files -- just appending the extension to an ht...
In ActiveRecord how can we update a record without worrying/knowing primary key.
If I do
Address.update(15, :user_name => 'Samuel')
it corresponds to
UPDATE addresses set user_name = 'Samuel' where id = 15
but what if i want to do:
UPDATE addresses set user_name = 'Samuel' where cid = 15
what will be the ActiveRecord equival...
I've been trying to debug some super slow performance in running my cucumber features. I've run various calls through ruby-prof and think I see the bottlenecks (not too familiar with using ruby-prof) but do not know the cause or more important the solution. I've include below the output from running rake cucumber.
http://dl.dropbox.co...
I'm using the simple_navigation gem with RoR 2.3.5
It all seems to work correctly, I followed the info in the RDoc (seen here http://rdoc.info/projects/mexpolk/simple_navigation)
However, when I actually render out the simple_navigation menu on my main application.html.erb file it escapes all of the html in it (multiple escapes actual...
I'm new to haml, so I'm still trying to figure out the formatting.
I have an index.haml file with the following code.
%h1
Welcome to Solidarity
Hello,
= @profile.first_name
!
It renders like this:
Welcome to SolidarityHello, user !
Here's the page source:
<h1>
Welcome to Solidarity
</h1>
Hello,
frances
!
It has a space...
I have just installed paperclip into my ruby on rails blog application. Everything is working great...too great. I am trying to figure out how to tell paperclip not to output anything if there is no record in the table so that I don't have broken image links everywhere. How, and where, do I do this?
Here is my code:
class Post < Active...
I want to run an instance of wordpress within my rails app. I currently have wordpress files housed in public/wordpress, but I need to configure my .htaccess file to allow both types of requests. How do I do that? currently, .htaccess is:
General Apache options
AddHandler fcgid-script .fcgi
RewriteEngine On
RewriteRule ^$ index.html [QS...
How can I achieve query string and URL parameters in a link_to block declaration? Right now, I have this, which works:
<%= link_to 'Edit', :edit, :type => 'book', :id => book %>
The above works, and outputs:
http://localhost:3000/books/edit/1?type=book
What I want to do is something like this:
<% link_to :edit, :type => 'book', :i...
Hi - I'm trying out rspec, and immediately hit a wall when it doesn't seem to load db records I know exist. Here's my fairly simple spec (no tests yet).
require File.expand_path(File.dirname(__FILE__) + '../spec_helper')
describe SomeModel do
before :each do
@user1 = User.find(1)
@user2 = User.find(2)
end
it "should do ...
Hi All,
I am using require 'digest/sha1' to encrypt my password and save into database. During login I authenticate by matching the encrypted password saved in database and again encrypted the one use enter in password field. As of now everything works fine but now I want to do 'Forgot Password' functionality. To do this I need to decry...
I create a action called "error404" in controller "pages", I would like to display this action if the following situation occurred:
the controller in URL is not existed
the action in URL is not existed
what should I do?
I tried to follow the instruction in this page, http://stackoverflow.com/questions/2553365/show-a-404-instead-of-5...
How do I force my float class to float:left regardless of wrapper width. I want the content which is called into the class g_photo to content going right, not to drop to the next line when it reaches the end of the wrapper.
html:
<div id="wrapper">
<% for gallery_photo in @gallery.gallery_photos %>
<div class="g_photo"><%= image_tag ...
Hi All,
I am just learning Rails. I had encountered a routing error, though I think I have specified the correct rules in the routing.rb. I have attached the code. Please help
routes.rb
map.connect ':controller/:action'
map.connect ':controller/:action/:id'
map.connect ':controller/:action/:id.:format'
Controller
class E...
Hi.
Is there something like Spork for Jruby too? We want to parallelize our specs to run faster and pre-load the classes while running the rake task; however we have not been able to do so.
Since our project is considerable in size, specs take about 15 minutes to complete and this poses a serious challenge to quick turnaround.
Any ide...