BrowserCMS can "delete" objects, which basically sets the :deleted attribute to true. Paperclip runs the following code initially to get all objects of a specific class:
Person.connection.select_values(Person.send(:construct_finder_sql, :select => 'id'))
This might return [1, 2, 3]. Even if, say, 3 has :deleted set to true. Paperclip ...
I'm going crazy here.
I have:
class Course
belongs_to :commune
end
and
class Commune
has_many :courses
end
In the new view for Course I have a drop down where the user selects commune:
f.collection_select(:commune, get_commune_list, :id, :commune, { :prompt => true })
(The get_commune_list is a helper method that returns ...
When I render a partial which does not exists, I get an Exception. I'd like to check if a partial exists before rendering it and in case it doesn't exist, I'll render something else. I did the following code in my .erb file, but I think there should be a better way to do this:
<% begin %>
<%= render :partial => "#{dynamic_part...
We wanted to convert a unicode string in Slovak language into plain ASCII (without accents/carons) That is to do: č->c š->s á->a é->e etc.
We tried:
cstr = Iconv.conv('us-ascii//translit', 'utf-8', a_unicode_string)
It was working on one system (Mac) and was not working on the other (Ubuntu) where it was giving '?' for accented chara...
Try to install feedzirra gem (http://github.com/pauldix/feedzirra)
Do this:
gem install pauldix-feedzirra
I get the following error:
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
ERROR: Error installing pauldix-feedzirra:
ERROR: Failed to build gem native extension.
...
So Authlogic ships with some pretty confusingly (for an end user) named routes. For example, instead of /login/new, you get /user_session/new, and so on. Then, when a user can't login, the error message appears as "This user session could not be saved."
It's a small thing, but that's just kind of... ugly, to me. What's a graceful way to...
Does anyone know any good methods for converting database entries into XML?
I.e. if i have a table named "Users" with fields "first_name", "age", "last_name", I'd like to convert the table to:
<Users>
<first_name>Papa</first_name>
<age>50</age>
<last_name>John</last_name>
</Users>
...
I'm working with Time in Rails and using the following code to set up the start date and end date of a project:
start_date ||= Time.now
end_date = start_date + goal_months.months
I then clone the object and I'm writing rspec tests to confirm that the attributes match in the copy. The end dates match:
original[end_date]: 2011-08-24 ...
This seems like a common task, I'm sure others have come across it.
If my controller says this :
def index
s = Sunspot.search Organization do |query|
query.keywords params[:q] unless params[:q].blank?
query.with(:searchable).equal_to(params[:filter_by] == 'published' ? 'true' : false) if params[:filter_by]
..
How do I:
....
I have the standard current_user methods in my application_controller.
def current_user_session
return @current_user_session if defined?
(@current_user_session)
@current_user_session = UserSession.find
end
def current_user
return @current_user if defined?(@current_user)
@current_user = current...
Hello,
I have a rails project which I am testing with rspec using script/autospec and it has been working great. However, I am now trying to add specs for a Vendor module in spec/lib/vendor/*_spec.rb and autospec ignores the files.
I have tried adding the following to .autotest based on the answer provided here with no success:
Autote...
I am completely new to Ruby and Rails... in fact I created my first application in Rails today that makes an HTTP request to pull back an XML document and then outputs it to the screen.. something simple to get started..
Well I am needing to now parse the XML string but am lost on how to do that exactly with Hpricot.
Here is my code so...
I have a rails app that needs to send out thank you emails to customers. I also need to have it so that there is a generic template that the user can edit before sending it off. I know I can do something like this with ActionMailer, but what I need to do is have it so that each user of the app can have a different email to send out of.
...
have a transaction model similar to RailsCasts ActiveMerchant tutorial.
How can I create a fake response?
Tried something like the following but no luck.
response = @success=true, @params = {"ref" => "123"}, @authorization = "54321", ...
models/order_transaction.rb
class OrderTransaction < ActiveRecord::Base
belongs_to :order
...
I have a simple if statement in my view that returns x = 0 or 1. Based on this simple result, I want to change the styling of the div that contains the entire section.
<div>
conditional that returns x=1 vs x=0 (and a few displayed items)
based on this loop, restyle the div
</div>
Let's say, if x = 1, I want to make background-colo...
I need to keep application's settings editable by admin users through web form. I've found rails-settings gem to keep hash of simple string settings. But app settings need to keep not only string parameter but lists of another models (e.g. PaymentPeriods with name:string, etc).
My question is: how to organize such app settings in the r...
Hello,
We (a group of 4 students) are planning to create a web-app on Ruby on Rails. I have done some web app projects in the past and one thing I have learned is the initial time devoted to design the app, which was very less, I just start coding with some basic things in my mind.
So, this time, I don't want to do the same mistake and...
Guys,
I'm trying my best to build a helper that outputs a <'ul> consisting of all the members of a collection. For each member of the collection I want to print out a <'li> that has a title, and a div of links to CRUD the member. This is pretty similar to what Rails outputs for scaffolding for the index view.
Here is the helper I've ...
I am trying to write a Rails app that takes an XML object and then iterates over the object showing the user the information contained inside the different nodes.
I am completely new to Rails, coming from a PHP background and am having some trouble with a particular function.
I need to basically say, if this node exists die, if it does...
I'm trying to query for records in the TimeSlot table by the field start_date which has type datetime. Here's what I've tried so far that's failed:
TimeSlot.where(:start_date => DateTime.new(2010, 9, 1))
TimeSlot.where(:start_date => DateTime.new(2010, 9, 1).to_s)
TimeSlot.where(:start_date => "2010-09-08")
TimeSlot.where(:start_date...