Hi, I want to display the column 'name' after being found from the table mytest.
In the mytest.rb, I defined "attrib_accessor :name";
In the procedure index under directory /controller/mytest_controller.rb,
def index
###[Ignore some code]
@[email protected]_by_id
### I am able to verify the tuples in @mytesttbl
end
In the /vie...
Why is there a need to define a new method in RESTful controller, follow it up with a create method?
Google search didn't provide me the answer I was looking for. I understand the difference, but need to know why they are used the way they are.
...
I'm using acts_as_solr for searching in a project. Unfortunately, the index doesn't seem to be updated for the associated models when a model is saved.
Example:
I have three models:
class Merchant < ActiveRecord::Base
acts_as_solr :fields => [:name, :domain, :description], :include => [:coupons, :tags]
...
end
class Coupon < Act...
I've been reading similar questions, but many of the answers are outdated or not clear enough for me.
I'd like to be able to just do something like (in a controller action):
respond_to do |format|
format.html
format.csv
end
I know I'd then need a view such as action.csv.erb
So my questions are:
1) What do I need to configure...
Hello,
Is there a way to test your application's processing and handling of Paypal generated credit card errors? I'd like to verify that my application can handle a declined credit card or something like that.
So is there a way to have Paypal send an error message? Or would it be better to generate a stub and use it in the testing envi...
This is a really noob question but im having trouble finding the answer, is there a way in rails to have 0 or 1 association? For example, I create a user with no objects, than later on create an object for that user.
I tried using build with a 'has_one' association but that blew up... The only way I see this working is using 'has_many'....
Hi,
I'm using acts_as_rated.
FYI: it is a rating plugin, you login, and if you haven't voted on something, then you can choose 1-5 stars. It works fine, except that it doesn't update 'ajaxfully'. It only updates the voting results after another refresh. So the code works because the vote is taken, it's just that the user doesn't see it ...
What is the most accurate way to determine the amount of cpu speed and ram needed to run my rails app?
I believe there are stress testing tools like Tsung, but how do I determine, for example, that I need X more ram, or X more CPU? I would like to find some way to roughly gauge the performance needs of my application so I can anticipat...
I have read through the Rails docs for Routing, Restful Resources, and the UrlHelper, and still don't understand best practices for creating complex/nested routes. The example I'm working on now is for events, which has_many rsvps. So a user's looking through a list of events, and clicks register, and goes through a registration proces...
Hi, I'm looking for a function grapher that I can use in a small Rails application I'm working on for my university. Is there anything out there? If it needs the values (points) is not a problem but it would be better if it just parsed the equation. The functions will be 100% in ruby format (for example Math.exp(3*x))...
Thanks a lot!
...
I have a model defined this way
class Lga < ActiveRecord::Base
validates_uniqueness_of :code
validates_presence_of :name
end
I've defined a factory for Lgas with
Factory.sequence(:lga_id) { |n| n + 10000 }
Factory.define :lga do |l|
id = Factory.next :lga_id
l.code "lga_#{id}"
l.name "LGA #{id}"
end
However, when I run
...
I was trying to write a validation for Rails to ensure that a price entered on a form was greater than zero. It works…sort of. The problem is that when I run it, val is turned into an integer, so it thinks that .99 is less than .1. What's going on, and how should I fix the code?
class Product < ActiveRecord::Base
protected
def sel...
I am using the rvideo gem to transcode files to a .flv format.
class Video < ActiveRecord::Base
include AASM
aasm_column :status
aasm_initial_state :initial
aasm_state :initial
aasm_state :converting, :exit => :transcode
aasm_state :transfering , :exit => :send_s3
aasm_state :completed
aasm_state :failed
aasm_eve...
This question came about because the cells gem specifies template directories using File.join('app','cells'). That works fine until you run Rails as a daemon (scripts/server -d). The daemon switches directories to / which leaves the cells template paths pointing to the wrong absolute path.
My solution was to set the default paths to Fil...
I have a typical, Post model:
class Post< ActiveRecord::Base
validates_presence_of :user_id #Line 1
validates_presence_of :title,:body #Line 2
in the controller, I have:
def create
if request.post?
if login_required
@post = Post.new(params[:...
Hi All,
I got RJS error: TypeError: element is null while using ajax.
I used in view
<%= periodically_call_remote(:url=>{:action=>'get_user_list', :id=>'1'},
:frequency => '5') %>
in controller
render :update do |page|
page.replace_html 'chat_area', :partial => 'chat_area', :object => [@chats, @user] if @js_update
end...
I'm not sure how to go about styling a custom theme Recaptcha widget using
http://github.com/ambethia/recaptcha
I want to resize the widget to fit in a form in a sidebar.
If I do
<%= recaptcha_tags :display => {:theme => 'custom', :custom_theme_widget => 'recaptcha_widget'} %>
and add
<div id="recaptcha_widget">
<div id="reca...
Hi,
I have 3 models
Recommendation
Job
Qualification
Recommendation model has two fields as work_type and work_id(foreign key for job/qualification based on work_type as "J"/"Q")
I am facing problem in using counter_cache
I have done this in recommendation.rb
belongs_to :job , :counter_cache => true, :foreign_key => "work_id"
b...
I have a good reason to use mongodb for part of my app. But people generally describe it as not a good fit for "transactional" applications like a bank where transactions have to be exact/consistent, etc.
Does it make sense to split the models up in Rails and have some of them use MySql and others mongo? Or will this generally cause...
In my main template I have the following:
<%= render :partial => "delivery_date", :collection => @brand.delivery_dates, :locals => {:form => f} %>
However when the partial tries to use the form local variable, I get this error
Showing app/views/brands/_delivery_date.html.erb where line #2 raised:
wrong number of arguments (0 for 1)...