I have a REST API which accepts XML in HTTP Posts.
When I send wellformed XML, the XML is parsed and put in the params object.
For instance:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<foo>
<bar>Hello</bar>
</foo>
is available as: "foo"=>{"bar"=>"Hello"}}
But when I send malformed XML, Rails logs a REXML::ParseExcepti...
Hi,
I'm looking for suggestions on how to track the number of tags associated with a particular object in Rails. I'm using acts_as_taggable_on and it's working fine. What I would like to be able to do is search for all objects that have no tags, preferably through a scope i.e. Object.untagged.all
My first thought was to use an after_sa...
Is there a way to fetch the model and the translations in one query when using globalize2?
For example, having a model called Language which have two fields, code and name of which the second is translatable I do the following:
en = Language.find_by_code("en")
and it runs this query:
SELECT SQL_NO_CACHE * FROM `languages` WHERE (`l...
I have two tables from the same DB that when one field is updated, a corresponding field needs to be updated in the second table with that information. How can I connect those fields (and tables) together using the Rails framework?
...
I have implemented the following custom link renderer class:
class PaginationListLinkRenderer < WillPaginate::LinkRenderer
def to_html
links = @options[:page_links] ? windowed_links : []
links.unshift(page_link_or_span(@collection.previous_page, 'previous', @options[:previous_label]))
links.push(page_link_or_span(@collec...
I am trying to test a couple models that have an attachment with Paperclip. I have all of my validations passing except for the content-type check.
# myapp/test/unit/project_test.rb
should_have_attached_file :logo
should_validate_attachment_presence :logo
should validate_attachment_size(:logo).less_than(1.megabyte)
should_validate_atta...
Hi All,
I m Trying to apply a class to following submit button
Code:
<input type="submit" value="Submit" name="commit" class="confirm-button-submit ">
css :
.confirm-button-submit
{
width : 79px;
font : bold 12px sans-serif;;
color : #000;
background : url("../images/confirm-btn.png") 0 -33px no-repeat;
...
I am trying to test a model's attributes for formatting with this:
# myapp/test/unit/comment_test.rb
require 'test_helper'
class CommentTest < ActiveSupport::TestCase
should_belong_to :article
should_validate_presence_of :name
should_validate_presence_of :email
should_validate_presence_of :content
should_validate_presence_of...
Let's say that
Post has_many :comments
and that
Comment has_many :ratings
How can I grab the last 5 comment ratings for each Post? I've been thinking of just looping through comment for each post but that wouldn't solve the Last 5 part.
EDIT: In response to J. since I can't seem to format code inside the comments field
Would you ...
In my website toolbar's I would like to display the number of unread messages in a red circle,
So I think the best way is to create a method in ApplicationController named update_notification :
def update_notification
@notification = 42
# 42 is just for test
end
and in application.html.erb, I display :
<%= render :par...
A while back I wrote this blog post (http://rywalker.com/chaos-2010) which didn't get any responses - my blog doesn't get a lot of traffic ;) So I want to try re-asking the same question here and maybe get some response.
We have the following systems (and more) that we push/pull data from one app to another:
Hosted CRM (InsideSales.co...
Hi...
I am using RPX for OpenID Authentication. I am getting the following error. It happens only in windows. It works perfectly in Mac. Can someone please guide me to solve this error.
OpenSSL::SSL::SSLError (SSL_connect returned=1 errno=0 state=SSLv3 read server c ertificate B: certificate verify failed)
...
Objective:
I would like to reset the array attribute of all objects in a class to []. The way they started.
My attempt:
> Deal.find(:all).update_attribute('votes', [])
Outcome:
Returns an error. How would you do this?
...
I'm working with Ruby on rails 2.3.8, NetBeans IDE.
I've installed paperclip and I could show/save images successfully. Now, I've installed ImageMagick-6.6.2-4-Q16(for windows 7, 64bits).
Until that moment, my model looked like this(and worked fine):
has_attached_file :photo
Now, after installing ImageMagick, when I add the :style l...
I have to sanitize a part of sql query. I can do something like this:
class << ActiveRecord::Base
public :sanitize_sql
end
str = ActiveRecord::Base.sanitize_sql(["AND column1 = ?", "two's"], '')
But it is not safe because I expose protected method. What is a better way to do it?
...
I'd like to implement measurement unit preferences in a Ruby on Rails app.
For instance, the user should be able to select between displaying distances in miles or in kilometers. And, obviously, not only displaying, but entering values, too.
I suppose all values should be stored in one global measurement system to simplify calculations...
Say I have a bunch of Models, Articles, Downloads, Videos, Pictures, I want to be able to have comments on all these models with a single Comment model so I can track comments made by a certain user across all these models. What's the best way to go about this?
...
Hello there, I'm struggling to get this working.
I have the following routes:
map.namespace :admin do |admin|
admin.resources :languages do |language|
language.resources :courses
end
end
So, basically an admin namespace and the languages models which has_many courses and obviously a course belongs_to language...
I've got an application running on Rails 2.3.5, on a Linux box, and I need to connect to Sql Server 2005 for one of my models.
I've been reading up on this, and it's getting frustrating, can't find a solution that works thus far. I've done this before using JRuby and JDBC, but I can't use Java in this scenario.
Any pointers to a failsa...
I'm sending a plain text email and was wondering how I add a line break to this. It's showing up on on the same line.
From: <%= @name %>
<%= @text %>
Thanks
...