I am developing a Rails application which will need frequent access to public APIs, and I am not sure what is best way to put external API (SOAP/WSDL) code in Rails application, what about model thingy, how we can manage that? Any ideas, comments?
...
I have a form I'm trying to set up ...
Users can have many posts, and each post can have many people watching it.
The Watch model is set up polymorphically as 'watchable' so it can apply to different types of models. It has a user_id, watchable_id, watchable_type and timestamps as attributes/fields.
This is soley so that when people c...
I m having a controller users in which there are three actions show, update and prepare and there respective views in views/users directory
Now when i am trying this:--
http://localhost:3000/users/prepare
I am getting an error
No route matches "/users/prepare"
can anybody explain me how to specify this routes in routes.rb for this...
module ActiveRecord
module Mixin
alias old_id id
def id
old_id.to_i
end
def hello
"hellooooooooooooo"
end
end
end
ActiveRecord::Base.send :include, ActiveRecord::Mixin
I make is because:
id column in oracle is number type,not number(10), @user.id return 123.0,not 123,so I would like to do it b...
I'm trying to figure out where a whole pile of extra queries are being generated by my rails app. I need some ideas on how to tackle it. Or, if someone can give me some hints, I'd be grateful.
I get these:
SQL (1.0ms) SELECT name
FROM sqlite_master
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
SQL (0.8ms) SELECT na...
I am using accepts_nested_attributes_for with the has_one polymorphic model in rails 2.3.5
Following are the models and its associations:
class Address < ActiveRecord::Base
attr_accessible :city, :address1, :address2
belongs_to :addressable, :polymorphic => true
validates_presence_of :address1, :address2, :city
end
class Vendor <...
I needed an id field in my rails migration that auto-increments from 0 and not 1.Any idea?
Thanks & Cheers !
...
Hi,
I want to insert a user in the userlist only if the user object (@row) is not nil. How do I do the insert conditionally in an rjs template?
page.insert_html :bottom, :userlist,
render(:partial => "user", :locals =>
{ :user => @row, :myid => @row.id })
thanks much.
...
I have a few constants which are arrays that I don't want to create databse records for but I don't know where to store the constants without getting errors.
For example
CONTAINER_SIZES = [["20 foot"],["40 foot"]]
Where can I store this so all models and controller have access to this?
...
Suppose this is my users controller:-
class UsersController < ApplicationController
def show
@user = session[:user]
end
def prepare
session[:user]= User.find(:first)
redirect_to :action => 'show'
end
def update
@user = session[:user]
@user.name = 'rai'
redirect_to :action => 'show'
end
end
View for show.html.erb
<%= @use...
Hello,
we are making a website that takes a generated incoming link and forwards the user who is clicking on it to another website while saving a record of the action in our DB. I guess it's basically what ad-services like AdSense do.
However, what is the best way to redirect the user?
I think html-meta-tag-redirects are out of questi...
I have a lib Class for a delayed job with httparty.
If I build my XML data in a view data.xml.builder and hand it to my lib Class everything works fine:
---
response:
status: !str
str: OK
"@attributes": {}
response:
status: !str
str: OK
"@attributes": {}
...
If I build my XML data directly in the lib...
The eager loading on Ruby on Rails is not working properly for the following scenario.
First we had a model called marks which has the following fields
id, student, subject, mark
the student is a string column which has the active directory login value, later on for reporting functionality we introduce another table called user which ...
Im using the following guide for getting started with rails for ubuntu 9.10.
http://guides.rails.info/getting_started.html
I have installed both ruby and gem.
gokul@gokul-laptop:~$ ruby -v
ruby 1.8.7 (2009-06-12 patchlevel 174) [i486-linux]
gokul@gokul-laptop:~$ gem -v
1.3.6
gokul@gokul-laptop:~$
For rails,
gokul@gokul-laptop:...
I don't know why I can't figure this out, I think it should be fairly simple. I have two models (see below). I'm trying to come up with a named scope for SupplierCategory that would find all SupplierCategory(s) (including :suppliers) who's associated Supplier(s) are not empty.
I tried a straight up join, named_scope :with_suppliers, :...
Is there a default location for where I should be storing the fonts?
Within rails I can't get the font to load, whereas with the 'font kit' downloaded from fontsquirrel.com where the font,css and sample html in the same folder will work.
this is my css
@font-face {
font-family: 'RalewayThin';
src: url('fonts/raleway_thin.eot');
src: ur...
I'm having trouble with and RSpec view test. I'm using nested resources and the model with a belongs_to association.
Here's what I have so far:
describe "/images/edit.html.erb" do
include ImagesHelper
before(:each) do
@image_pool = stub_model(ImagePool, :new_record => false,
:base_path => '/')
...
I installed the autotest gem and intend to use it with rspec. The problem is, when I run autotest under my rails app, all I see is :
railsapp$ autospec
loading autotest/rails_rspec
And its stuck there until I Ctrl-C out of it. Nothing changes even if I change a rspec test or code.
Here's my ~/.autotest
require "auto...
I have installed will_paginate and acts_as_ferret on my system for ruby rails.
My paginate seems to work fine before installing acts_as_ferret. When I put in the code to do searching I get the following error:
NoMethodError in Community#search
Showing app/views/community/_result_summary.rhtml where line #3 raised:
undefined met...
I am trying to cleanup my specs as they are becoming extremely repetitive.
I have the following spec
describe "Countries API" do
it "should render a country list" do
co1 = Factory(:country)
co2 = Factory(:country)
result = invoke :GetCountryList, "empty_auth"
result.should be_an_instance_of(Api::GetCount...