I am teaching myself rails (coming from PHP for web apps) and I can't find any good docs to help me. But I was wondering how would you tell your method to take the last post(controller is post) in the database? I tried Post.find(:last) but that did nothing sadly. Anyone know?
...
I have rake task to seed the application with random data using the faker gem. However, we also have images (like logos) that we want uploaded in this rake task.
We already have Paperclip set up, but don't have a way to upload them programmatically in a rake task. Any ideas?
...
When I log in on my dev machine in an ROR application, I should be redirected to http://sitename/user/dashboard. This was happening successfully before, till I began developing on it :). Now it tries to go to http://sitename/user/images/navarrow, which results in the error ActionController::UnknownAction (No action responded to images).
...
What do I have to do so that this will work in the console (assuming song is defined, obviously):
edit_song(:id => song.id)
...
Hi There,
I want to derive from a c++ class in ruby and then pass an instance back to a c++ call. Specifically I want to derive from Xapian::Weight (http://xapian.org/docs/apidoc/html/classXapian%5F1%5F1Weight.html) and then tell Xapian to use my implemention.
I have Xapian talking correctly with acts_as_xapian, but can't get to accept...
What's the best plugin these days for implementing voting on a Rails site?
Two I'm aware of are:
vote_fu
acts_as_voteable
...
Hi,
The following code is for a button to make a ajax call. I am trying to add css to the button to no avail.
<%= button_to_remote "Close sales period",:url=>{:controller=>'admin',:action=>"closure"},:class=>"button close" %>
.close_sales_period
{
background: url(/images/buttons/close_sales_period.gif) no-repeat;
}
.button
{
...
I have Rails 2.3.3 installed and jrails_auto_complete plugin seems not to work:
# View
text_field_with_auto_complete :photo, :place
# Controller
auto_complete_for :photo, :place
# Routes
map.auto_complete ':controller/:action',
:requirements => { :action => /auto_complete_for_\S+/ },
:conditio...
Hello Everyone,
I have an application in rails (uses authentication via AuthLogic).
I want to login to my PHP application by remotely logging on to my rails app.
I want the PHP app to use my Rails app to perform the authentication and retrieve user details on a successful login else echo error from my rails app.
In shorter words,
Log...
I have a class like so:
class Item
attr_accessor :item_id, :name, :address, :description, :facilities, :ratings, :directions, :geo, :images, :video, :availability
def self.create options={}
item = Item.new
item.item_id = options[:item_id]
item.name = options[:name]
item.description = options[:desc]
item.ratings ...
I want to test how priorities are working in the delayed_job plugin. Im using the mailit app from railscasts. I think i want to send 100 messages with a high priority and 100 with a lower priority. And i want to see if the messages with a lower priority will be delivered on time or they will be put aside.
How can i do a test like this....
Apparently dependent => destroy is ignored when also using the :through option.
So I have this...
class Comment < ActiveRecord::Base
has_many :comment_users, :dependent => :destroy
has_many :users, :through => :comment_users
...
end
...but deleting a Comment does not result in the associated comment_user records getting deleted...
In order to keep things DRY and share functionality between my Rails tasks and my "app", I put a lot of functionality in models. In my models I have "logger.info ..." but this is problematic when I call the model functions from rake tasks because nothing is logged. Is it possible to redirect logger for only rake tasks but have it log n...
Can anyone tell me how to detect faces in a static picture using Ruby or Javascript?
...
I assume this is really easy, and I'm missing something obvious. I'm connecting to a legacy database that has column dblOrderQty. I'm validating it thusly:
validates_numericality_of :dblOrderQty, :greater_than => 0
This, of course, presents "Dblorderqty must be greater than 0". I'd much rather have that say "Quantity must be greate...
I have an object now:
class Items
attr_accessor :item_id, :name, :description, :rating
def initialize(options = {})
options.each {
|k,v|
self.send( "#{k.to_s}=".intern, v)
}
end
end
I have it being assigned as individual objects into an array...
@result = []
some loop>>
@result << Items.new(opt...
I have code similar to:
number_to_currency(line_item.price, :unit => "£")
littering my views in various models. Since my application deals only in GBP (£), should I not move this into each of my models so that line_item.price returns the string as it should be (i.e. number_to_currency(line_item.price, :unit => "£") and line_item.price ...
Most of the Rails books I have touch on script.aculo.us and prototype, but because the Rails framework is so large, they don't spend a lot of time going in depth on the two packages.
I really like Agile Web Development with Rails (3rd Ed.), so I was leaning towards picking up another book from Pragmatic Bookshelf specifically on script....
Xcode's syntax colouring is poor at best and textmate's looks great, but I like Xcode, since I program in C++, too. I'd like to keep everything in one place and take advantage of other Xcode features.
Has anyone already done this or is there an easy way to do it?
...
I have a datetime column in a model and I want to display the form for this as separate text_fields for the time instead of the datetime_select helper drop down menus.
I know I will somehow have to validate and recreate the date to go back to the DB, but I am not sure how.
Should I use virtual attributes getter and setter methods? EG.....