I want to create a list from a class' attributes
I'm new with ruby- i have an activerecord class called fixture and what an array of "Home Team", "Draw", "Away team", where home team and away team are both fields in the Fixture table
I have come up with the following code sticking it in the Fixture class- how do access the values of th...
Hi,
I have two models, frontend and user with respective controllers and views.
From a form_for in frontend view I'm calling a create method in user controller and I save new user in database. All works.
The problem comes with validation.
If something is wrong with the model validators I need error messages to be displayed on frontend...
I've spent the majority of my professional career developing in C#. To broaden my abilities I've recently begun learning Ruby on Rails. Thus far I've found scaffolding a basic CRUD app in RoR to be easy and fun. I am well aware that I have barely scratched the surface of what RoR is capable of but am curious if there is anything I should...
How can I pass a method with an argument to #to_xml?
@object.to_xml(:methods => [:a_method_with_args] )
Is there a way to do this? What is the correct syntax?
Thanks.
...
I am trying to build a simple shopping cart with rails, now I am able to add products to cart, I want to know how can I edit products while they are in cart, I am using sessions to control the products in shopping cart. here is what the user see when add to cart :
<% @cart.items.each do |item| %>
<tr>
<td>
<%= image_tag item...
I can't seem to wrap my mind around Rails associations. Let's say I have 3 tables. One for Users, one for Recipes, and one for Ingredients. Here's an example of the database (in yaml):
Users:
id: 1
email: funnyusername
password: pass1234
Recipes:
id: 1591
user_id: 1
name: Pizza Dough
Ingredients:
id: 1
name: Flour
i...
Hello Friends,
We need a Rails plugin for US states and cities. Please see if we can get that.
...
When I try to hit this action via Javascript, I get a 406 Not Acceptable error:
def show
@annotation = Annotation.find_by_id(params[:id])
respond_to do |format|
format.html {
if @annotation.blank?
redirect_to root_path
else
redirect_to inline_annotation_path(@annotation)
...
Installing rails plugins from github requires git in the system?
OS is linux. Is it possible to install plugin without git installation in the local system.
...
I am currently beginning with BDD - I have not written any tests before.
I always try to keep my models fat and my controllers skinny.
What do you think - are controller specs necessary?
Best regards
...
Hello,
I'm using Rails and I have a User Controller for creating new users. To view current users I have to type something like:
mysite.com/users/USER_ID
I want to change to:
mysite.com/USER_ID
What is the best way to acheive that?
Thanks,
Tam
...
Hi,
I know a very, very similar question has been asked before. The hackish solution to that question doesn't work if I want to chain in more scopes, so I'm asking again here, with a bit more information as to where the issue is coming from.
# Relevant code only...
class Publication < ActiveRecord::Base
has_many :issues
has_many :a...
Is there anything better than string.scan(/(\w|-)+/).size (the - is so, e.g., "one-way street" counts as 2 words instead of 3)?
...
For some reason times are appearing differently in development (my local Mac) and production (Heroku). Take a look: (Just prior to doing this I did a heroku db:pull, so the databases should be identical)
Production (Heroku)
>> Annotation.last.id
=> 2028
>> Annotation.last.created_at
=> Sat, 12 Sep 2009 06:51:33 UTC +00:00
>> Time.zone
...
I have a book model and a tag model and a join model. The book model has many tags through the join model. How do find books that have both tag 'A' AND tag 'B'?
This works for Just A:
Book.all(:joins => 'tags', :conditions => {'tags.name' => 'A'})
This works for A or B (or seems to):
Book.all(:joins => 'tags', :conditions => {'tags...
I have a partial for a "guest" object which renders a link to a destroy action like this:
<%= link_to_remote "remove", :url => { :action => "destroy", :id => guest.id } %>
When called from an ERB view it works fine, e.g.
<div id="guests">
<%= render :partial => @event.guests %>
That is, it renders something like:
<a href="#"...
Hi,
My regex is poor and letting me down so some help would be great here.
All I want to do is return all the links which appear in a tweet (just a string) - Some examples are:
"Great summary http://mytest.com/blog/post.html (#test)
"http://mytest.com/blog/post.html (#test)
"post: http://mytest.com/blog/post.html"
It should also s...
We have an existing WordPress install with a thriving user base.
There are also some new Web applications being built in Rails to cover some new functionality.
Any suggestions or tips on integrating sign-on between WP and a Rails app?
Anyone done anything like this before?
...
Im trying to add an extra field to one of my tables.
Ive added the field in the migration file (under db\migrate)
then ran 'rake db:migrate' which ran without troubles and my text editor even told me my schema.db file has been updated and needs to refresh.
The schema file does not contain my new field and any attempts to reference the ...
My votes table looks like this:
id: integer
vote: boolean
voteable_id: integer
voteable_type: string
voter_id: integer
voter_type: string
The vote column determines whether the row represents an "up vote" (vote = true) or a "down vote" (vote = false).
voteable_type is the class of the thing being voted on, voteable_id is the id of th...