In my rails app I have two models that are related by has_and_belongs_to_many. This means there is a join table.
Imagine the scenario where I am adding users to a game. If I want to add a user, I do:
@game.users << @user
Supposing that I want to know in what order I added these users. I can do this:
@game.users.each do....
My qu...
Hi,
I'd like to enable the business analysts to be able to write all of their specs for features, scenarios and steps that is Cucumber friendly using Gherkin.
I've read some of the basic info on the github site for Cucumber and from doing a quick Google search but wanted to know if there were recommended resources for getting non-techn...
Good friends of stackoverflow, I am here today for guidance regarding image processing/manipulation using Ruby in a Rails environment. I'm creating on-the-fly dynamic banner ads that will feature mostly (if not completely) text. It's fairly simple with just a line or two, but I'd like the option to adjust font, text color, text size, etc...
Hey, need a little help here.
I have two models:
class User < ActiveRecord::Base
has_many :jobs
end
and
class Job < ActiveRecord::Base
belongs_to :user
end
When i do migration i put
class CreateJobs < ActiveRecord::Migration
def self.up
create_table :jobs do |t|
t.references :user
.....
What should i put on my ...
Essentially, my route is working perfectly, Passenger seems to be loading - all is hunky-dory. Except that nothing Railsy happens. Here's my Nginx log from starting the server to the first request (ignore the different domain/route - it's because I haven't moved the new domain over yet, and it's returning a 403 error because there's no i...
I'm working on a web application right now using Rails and wanted to see if anyone knew of a good way to keep track of file storage limits? We want to give users a specific amount of room that they can use to upload files and we are using paperclip for storage on Amazon S3. Any thoughts? Thanks
...
Simple issue but can't seem to find an answer doing some quick Googling. What's the Rails way of doing this 301 direct (http://x.com/abc > http://www.x.com/abc). A before_filter?
...
How do I get only first (say) 200 characters from my object Article (which is in a table articles with aattributes content and title)?
Thank you
...
Hi guys,
A really dodgy problem I've got. Here's my model:
class Entry < ActiveRecord::Base
default_scope :order => 'published_at DESC'
named_scope :published, :conditions => ["published_at < ?", Time.zone.now], :order => 'published_at DESC'
belongs_to :blog
end
Now if I do
@entries = Entry.published.paginate_by_blog_id @blog....
I have an Event model, which stores an event feed for each user. I also need to email the updates to users which have enabled email notifications in their profile.
From an architectural point of view, which one is better?
call the mailer in an after_create method in the model, since it's a part of the business logic;
call the mailer i...
I usually get the typical red error message when errors occur in my staging environment but lately the errors have been resulting in a blank screen. Is there a way to explicitly tell Rails to raise the typical error message in specific environments?
...
I wonder if there is a way for me to store ruby on rails view files into database store and have that fetched directly from there. The reason is I want to create a CMS with all the user data stored in database, so I would like to have the template stored in database but still retain the whole ActionView mechanism.
...
Hello guys,
We have an admin application used to manage member data and it was built in 2.1, has been running for about a year. Now that all inputs and data massage is done, our client wants to start building member site, members will have access to data the administrators have been inputting.
Here's the question, should we start a new...
i want to render a partial within a view. so that when button MORE is clicked everything stays the same just additional characters are shown. in my case the whole article.
<%= @article1.content[0..300] + "..." %>
<%= link_to "more", ....... %>
i dont know what the right methot would be. somehow i have to explain to rails that when bu...
Hello,
I installed the ruby on rails plugin "open_id_authentication". After running the migration it created two tables "open_id_authentication_associations" and "open_id_authentication_nonces" does anyone know what those tables do and how they are used?
Thanks
...
Hello.
How can I remove img tag/s using nokogiri?
I have the following code but it wont work:
f = Nokogiri::XML.fragment(str)
f.search('//img').each do |node|
node.remove
end
puts f
Thanks for help!
...
Class A and B are identical:
class A < ActiveRecord::Base
def foo
puts "foo"
end
end
class B < ActiveRecord::Base
def foo
puts "foo"
end
end
What's the difference between refactoring like this with a base class:
class Base < ActiveRecord::Base
def foo
puts "foo"
end
end
class A < Base
end
class B < Base
end
versus li...
i am testing an application built with rails and from time to time get bugs
when it happens, ActionView::TemplateError occurs and gets logged in log/production.log
how do i catch it and f.ex. send myself by email whenever it happens somewhere in the app?
what is the best way to do that?
f.ex. in ApplicationController with some sort o...
Hi, I am having a problem Scraping Code i require to extract information for a Web MashUp i'm creating.
Basically, I am trying to Scrap Code from:
http://yellowpages.com.mt/Meranti-Ltd-In-Malta-Gozo;/Hair-Accessories;Hijjhkikke=Hiojhhfokje.aspx
This is just one of the pages i will need to scrape and hence i cannot feed the program d...
I've got this line of code:
if request.user_agent.include?("iPhone") then
But I'm occasionally getting this error:
"undefined method `include?' for nil:NilClass"
When checking logs on the error, there isn't a "HTTP_USER_AGENT" for the user that is getting the error.
So how can I fix that line so it doesn't throw an error if there ...