I am trying to parse an xml file with hpricot. The xml element that I am trying to get has a dash though and hence the issue that I am facing
xml
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.1" version="1.1">
<trans-unit>
<source>"%0" can not be found. Please try again.</source>
<target>"%0" can not be found. Please try ...
I'm sure this is easy once you know rails but I'm new to it...
I want to redirect to another page/action after the submit button (f.submit) is pressed, and only after it is pressed. How do you determine the link that you go to after the submit button is pressed?
...
We started to use memcache-client in our rails app and it works just fine with "script/server" but "mongrel_rails start" fails with an error.
In environment.rb we define "memcache-client" and version "1.8.1". Gem list shows that the gem is installed: memcache-client (1.8.1).
If run with "script/server" everything works but with "mongr...
I am trying to pass some filters in my params through a form like so:
hidden_field_tag "filters", params[:filters]
For some reason the params get changed in the next page. For example, if params[:filters] used to be...
"filters"=>{"name_like_any"=>["apple"]} [1]
...it gets changed to...
"filters"=>"{\"name_like_any\"=>[\"apple\"]}"...
I have some STI structure like following:
class Assignment < ActiveRecord::Base
has_many :criteria, :class_name => "Criterion", :order => :position
end
class Criterion < ActiveRecord::Base
# Represents a criterion used to mark an assignment that
# being the super class for all different criterias
set_table_name "criteria" # se...
Hi all:
I am just starting to write ruby rails. I wrote a controller but is getting wrong number of "arguments (1 for 0)" error, I can't understand why. It has no information on where the error occurred? It has a full list of stack traces but my controller file is not in there!
In my controller I have just two methods, that I was going...
I have a controller without any related model. This controller is to span some information from various models. I have lots of actions there, which define certain views on the page. What would be the best way to organize routes for this controller?
What I would like is to have /dashboard/something point to any action in the dashboard c...
I'm use Rails 2.2.2.
Rails manual said, the way to extend controller from plug-in is:
Plugin:
module Plug
def self.included(base)
base.extend ClassMethods
base.send :include, InstanceMethods
base.helper JumpLinksHelper
end
module InstanceMethods
def new_controller_metod
...
end
end
module ClassMethods
end
end
...
I have a comment model, I've seen examples of using @comment, :comment, comment to reference the object in MVC. how do I know which is which? Is there a distinction?
...
I am trying to get put out a simple site, which would pool the database every few seconds and update the information on the page dynamicly, when theres something new inserted.
I am farily new to ruby, but I understand the whole concept of RJS, link_to_function and soforth. The question is, what is the best way how to implement some kind...
I am building a framework that will validate forms both client-side (javascript) and server-side based on a form requirements specification written in json.
The purpose is to get rid of logically equivalent code on the server and client to make the code more maintainable, faster to write, and less buggy.
The specification format may ...
I have a controller action that generates a number of excel reports, this takes about 10 minutes to do. Sometimes I call it from my webapp, which is why it is an action.
But I also want to create a rake task to run this, so I can schedule it to automatically run once a night.
Any way to do this?
...
According to the Thinking Sphinx docs...
Turning on delta indexing does not
remove the need for regularly running
a full re-index ...
So I set up this cron job...
50 10 * * * cd /var/www/my_app/current
&& /opt/ruby/bin/rake thinking_sphinx:index RAILS_ENV=production
>> /var/www/my_app/current/log/reindexing.log 2>&1
Is...
Hello,
I'm developing a "script generator" to automatize some processes at work.
It has a Rails application running on a server that stores all data needed to make the script and generates the script itself at the end of the process.
The problem I am having is how to export the data from the ActiveRecord format to Plain Old Ruby Object...
Hi all,
I'm playing around with a fork of acts_as_taggable_on_steroids as a learning exercise. The version I'm looking at does some stuff I don't understand to calculate Tag counts. So I thought I'd do a version using PORC (Plain Old Rails Counters):
class Tagging < ActiveRecord::Base #:nodoc:
belongs_to :tag, :counter_cache => "tag...
class Followup < ActiveRecord::Base
belongs_to :post
belongs_to :comment
end
This model needs to only have either a post or a comment, but only one of the two.
Here's the rspec for what I'm trying to do:
it "should be impossible to have both a comment and a post" do
followup = Followup.make
followup.comment = Comment.m...
I must be missing something very simple, but can't find the answer to this. I have a method named foo inside bar_controller. I simply want to call that method from inside a functional test.
Here's my controller:
class BarsController < ApplicationController
def foo
# does stuff
end
end
Here's my functional test:
class BarsC...
i am wondering if the :with attribute is removed from rails3 since i cannot find anything in the rails3 api - http://rails3api.s3.amazonaws.com
anyone has a clue or give a hint on how to use the :with parameter to send data with a link_to
non-working example:
= link_to "Foo", {:action => "filter", :filter => "filter1",:with => "'test=...
I am using Rails 2.3.5.
Class User < ActiveRecord::Base
has_many :phones
end
class Phone < ActiveRecord::Base
has_many :frequency_bands
end
I want to get all the frequency_bands for a user. I know I can write a method def freq_bands for User but I would like to know if it is possible to have has_many freq_bands for a User. In thi...
I'm digging through some interesting code which I'm convinced is wrong. I wondered whether anyone had a thought as to the syntax the developer was trying to use?
Heres' the bogus code:
render :nothing => true and return if params[:name].nil?
My naive fix alludes to my programming language background:
if params[:name].nil?
render :...