What's the preferred way to handle rich text user input in rails? Markdown looks useful, but I haven't found an editor that looks simple to setup for it, nor am I sure how to handle sanitizing the html. (the sanitize helper still seems to allow stuff like </div>, which breaks my layout) I'd like to guarantee that the cleaned up code is v...
I have a directory called cron, inside my app directory. In the cron directory, I have put my cron file. How do I access the model inside my cron file?
Which is the best place to put my cron file?
edit:
I'm trying to execute the cron file, directly like ruby cron.rb
...
I'm trying to make a helper which automatically picks the correct partial based on the types of objects returned by either ActiveRecord::Base#find or an association. Unfortuneatly I can't just look at the first element of the returned array because I want to pick the correct one in this case as well. If you call an association, it return...
I am learning web development and I'm very serious about trying to find a career in it. That being said, I have consistently been told that "doing" is the best way to learn and now I have a vision for a site that I would like to create. I have spent some time with learning frameworks to find a preference, such as Rails, Django, and .NE...
Hi,
I'm using a rails plugin call acts_as_translatable. The plugin modify the sql sent to the DB to enable multiple translation a the model level.
The plugin works good with SELECT statement, through the override of the ActiveRecord::Base::construc_finder_sql method. However, it does not work for update statements. I am tring to fix i...
Warning: some of this may be very wrong-headed, so please let me know if my assumptions are incorrect.
Here's what I'm trying to accomplish:
I'm using restful-authentication for login. However, as I am using flex/ruby_amf for my UI, I have to separately authenticate each connection from flex.
The way I decided to do that was by havin...
I would like to use HTML 4.01 Strict, and used a DOCTYPE of it in my application template. But look like when a style sheet is included by a helper function
<%= stylesheet_link_tag 'style' %>
the code produced is XHTML:
<link href="/stylesheets/style.css?1243210734" media="screen" rel="stylesheet" type="text/css" />
is there a ...
How do I change this bit of code so that I only allow pdf files to be uploaded:
unless @file.content_type =~ /^image/
errors.add(:file, "is not a recognized format")
return false
end
...
Are any alternatives to the Active Record in Rails?
...
I am using Rails and jquery with RJS templates to perform various AJAX requests.
For most of my Ajax stuff I attach a submit handler to the form in my application.js as follows:
$('#tagging_flickr_photos').submitWithAjax();
$('#tag_submit').click(function() {
$('#flickr-photos-status').show();
});
This calls the form action whic...
I'm trying to use Thinking Sphinx for my Product model. It is also translated with Globalize2. Which makes a bit of a problem. Because obviously, no straightforward approach like this
class Product < ActiveRecord::Base
translates :title, :description
define_index do
indexes :title, :description
end
end
would work s...
One of the things that bothers me in Rails is that scaffolding generates migrations that I don't always need.
Is there a way to generate the scaffold without the corresponding migration?
...
I have a feeling I'm just doing something wrong syntactically but it's surprisingly difficult to Google "GET" so I was hoping someone here might know the answer to this.
I'm trying to test a Rails controller from an RSpec test. I'm following an example I found here - http://www.elevatedrails.com/articles/2007/09/10/testing-controllers-...
To add the phone column to the tickets table, I can write:
ruby script/generate migration AddPhoneToTickets phone:string
There seems to be a redundancy here. But is it necessary?
Aren't we repeating ourselves by being required to specify "phone" both in the name of the migration (AddPhoneToTickets) as well as in the column definiti...
If I say this in the controller:
@order = Order.new(params[:order])
What is required for this to work?
Does there need to be a one-to-one match between all of the fields in params[:order] and the Order model?
Or can there be more or fewer fields in params[:order] than are required to instantiate an Order?
...
I find it confusing that there is an ActiveRecord delete as well as destroy.
In my Controller I want to delete a user in my delete action.
The result would be that this instance represented by the User model no longer exists in the database.
Which method should I use for this?
...
Hi, I am trying to send a jquery ajax PUT request that looks like this:
$.ajax({
type: "PUT",
url: '/admin/pages/1.json',
data: { page : {...} },
dataType: 'json',
success: function(msg) {
alert( "Data Saved: " + msg );
}
});
but I get the following error:
The er...
Hi, I am trying to send a jquery ajax PUT request that looks like this:
$.ajax({
type: "PUT",
url: '/admin/pages/1.json',
data: { page : {...} },
dataType: 'json',
success: function(msg) {
alert( "Data Saved: " + msg );
}
});
and my controller looks roughly like this:
respond_to do |...
<%= link_to 'Edit', edit_order_path(@order) %>
Is it possible to wire this link to the modify action of the Orders controller (instead of the edit action) without changing this syntax:
edit_order_path(@order)
...
When I run a rake task for an application that uses Models defined in a plugin I get an Uninitialized Constant error, but when I run the model process, with script/runner, that is fired in the rake task then the job runs fine?
Is there some difference between script/runner that loads all my plugins that doesn't happen when I fire up a r...