Is there a way to do this in Rails:
I have an activerecord query
@posts = Post.find_by_id(10)
Anytime the query is called, SQL is generated and executed at the DB that looks like this
SELECT * FROM 'posts' WHERE id = 10
This happens every time the AR query is executed. Similarly with a helper method like this
<%= f.textarea :name...
I am trying to create a plugin and use it in my project.
I created a plugin using 'ruby script/generate plugin pluginname' and added the necessary code in the rb file in lib. I added 'require File.dirname(FILE) + '/lib/pluginname' in init.rb file
I added the pluginname in my controller where I want to use it..and it throws me an except...
I need to relate a Comments model with two ids at the same time but can't figure out how. Here' my situation. I am building an on-line school grading system and need to be able let the teacher make a comment on a particular student in a particular course for a particular term (grading period).
class Course
has_many :course_terms
h...
I am so sorry if this question seems too easy but I can't seem to find it anywhere. I am creating a ruby in steel project. I have created a html.erb and rb file in a vs project (ruby on rails).
My problem is the following:
In my html1.erb file I have created a text box and button:
<p>
<input erb:blockvar="erb:f" erb:method="erb::myName...
Im having a little trouble setting up routes.
I have a 'users' controller/model/views set up restfully
so users is set up to be a resource in my routes.
I want to change that to be 'usuarios' instead cause the app will be made for spanish speaking region... the reason the user model is in english is cause I was following the authlogic...
I am working on ruby rails project. I am using Rails 2.3.4 and ruby 1.8.7 . I have a model called User.
I have following code in initializer
$h = {User => 'I am user' }
In the controller I have following code
$h[User]
First time when I do h[User] I get the right result. However if I refresh the page then I get nil value.
I thi...
I'm try to install google-geocode for rails
sudo gem install google-geocode
but I get the following error. Any suggestions?
Building native extensions. This could take a while...
ERROR: Error installing google-geocode:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/r...
i know nothing about ruby but a lot about php.
when you code in ror...do you actually understand what is going on under the surface if you are a beginner? and do you HAVE TO understand it or is it good enough just to know enough to build something fast?
Looking for experiences from people who have made the transition.
...
I am still fairly new to rails and activerecord, so please excuse any oversights.
I have 3 models that I'm trying to tie together (and a 4th to actually do the tying) to create a permission scheme using user-defined roles.
class User < ActiveRecord::Base
has_many :user_projects
has_many :projects, :through => :user_projects
has_m...
Maybe I am over complicating this in my head but I just don't know what to do next...
I have a slice configured with MySQL, Rails & Passenger. I am setting up a new slice to separate the front-end from the database. The current server will become the database server and the new front-end will connect to it. I am using Ubuntu 8.10 on b...
I am trying to run an active record migration but am receiving the following error:
undefined method 'info' for nil:NilClass
Here is the 2 lines of code in my rake task that runs the migration
ActiveRecord::Base.establish_connection(YAML::load(File.open('src/SupporterSync.Core/Database/Database.yml')))
ActiveRecord::Migrator.migra...
I'm using delayed_job with capistrano and would like a way to start delayed_job on startup of the web application using the 'script/delayed_job start'. This way capistrano can restart it on deploy. If the server gets rebooted then my delayed_jobs should start up with the project.
How can I do this?
Should I be looking at doing this in...
Hi, I've come across an issue which unfortunately I can't seem to surpass, I'm also just a newborn to Ruby on rails unfortunately hence the number of questions
I am attempting to scrape a webpage such as the following:
http://www.yellowpages.com.mt/Malta/Grocers-Mini-Markets-Retail-In-Malta-Gozo.aspx
I would like to scrape The Addres...
I have two models:
Novel has_many :pages
Page belongs_to :novel
I want to list popular Novels according to page count. Essentially, I want Novel models loaded from the outcome of this query:
select p.novel_id, count(*) as count
from pages p
GROUP BY p.novel_id
ORDER BY count DESC
I'm sure there's some cute way to do it in Rails 2....
I right clicked the project file for my rails project and created a new ruby file.
Then i right clicked views and created a new erb file
I added a textbox and submit button and click on page (design) and it gives me this error:
failed to locate layout file
can anyone help me pleasE?
thnx
...
Hi,
I am using Rails (Facebooker). This is for Facebook apps (FBML) and to keep it simple, let's assume it's a student registration system.
In my student page (displaying their photo, name, grade etc), I have an 'edit' button. Clicking that button, will display a FB-dialog to edit their details.
My aim is simple. I want the user to be...
Greetings all.
My application works with a remote server. Server uses https
authorization of the certificate. I have following code to authorize and
sends request:
uri = URI.parse("https://db1-test.content.ertelecom.ru/")
http = Net::HTTP.new(uri.host, '443')
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
http.ca_file...
I have some players and the players have a trade state. Rather than hard code trade states like "active" and "inactive" and then have to go looking for strings, I thought I'd be clever and have a separate TradeState model so that a Player has a trade_state_id (a Player can be in only one trade state at a time).
Now, it would be a conve...
Hey!
I have users registration procedure on my app. But my users have to register with promo code.
So I have model Promocodes for that:
t.references :user #this is who have create that promo, e.g. Admin
t.string :name #a "name" for promo, e.g. "some_promo"
t.integer :allowreg #how much registrations can be done using that promo ...
I have been hearing a lot of buzz around has_many :through(HMT) vs has_and_belongs_to_many (HABTM). This post covers most of its benefits. Okay, HMT sure has some real good benefits over HABTM. However, what I wanted to know that when should I know that I should be using HMT over HABTM? Often I am in a situation where I believe that plai...