I'm trying to write a migration that adds a LONGBLOB column to a table in a MySQL database. I'd like to use LONGBLOB instead of BLOB so that I can store more data in the binary column. The problem is that it adds a BLOB column even though I specify a larger size.
Here's the line I'm using to add the column:
add_column :db_files, :dat...
Since I didn't get the expected answer on my last question I'll try to simplify and narrow my question:
How can I build a dropdown-menu that uses AJAX (no submit-button) to call the show action of a certain controller?
The following things are given:
Model-Association is Categories HABTM Projects, therefore the dropdown-menu consi...
Trying to use the nested model form in the new rails release candidate. I have this, but it only renders form fields for each existing associated photo object.
(Given a form builder f that was created for my parent model object)
%h3 Photos
- f.fields_for :photos do |photo_form|
%p
= photo_form.label :caption
= photo_form.te...
I've got a gem (will_paginate) that's broken on my version of Oracle. The default paginate_by_sql method in the WillPaginate module is inserting an extra 'AS' into a query and causing it to fail.
The code itself is easily fixed, but i'm not sure of the best way to get rails to pick up my change.
I don't want to change the code in the ...
Every time I try to run any class from my rails 2.2 app's lib directory using "script/runner -e production ClassName.run" I get the following error:
"/usr/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/commands/runner.rb:47: /usr/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:89:in `const_missing': uninitialized c...
I use Apache + Passenger to host some Rails applications. Something seems to go in a sleep mode when there is no request for a longer time. It then takes 10-20 seconds for the site to load. Feels like there is something that has to wake up when there have been no requests for a longer time.
How can I fix that? I have enough RAM so it sh...
Hey! I iterate through a hash with @lists.each do |list|. I create a div in every cycle that must have an id. I would have created a count variable in PHP to get a definite id. What is the best way to do that in a Rails view? Thank you!
...
I want to display a list with tags plus the number of elements (in my example "Tasks") for each tag.
For this purpose I created the following method in my Tag model:
def self.find_with_count
find_by_sql 'SELECT
Tag.name,
COUNT(Tag.name) AS taskcount
FROM
tags AS Tag
...
I am building a mechanism for sortable columns in tables. Every table represents a list of data so I call the database table "lists". Everything except the ordering of the columnpositions works. I want to display the columnpositions ordered by the field "position" but nothing changes even if I remove the :order statement.
list.rb :has_...
Hi all,
I'd like to render multiline text in Rails, the action looks like:
def mutli_text
render :text => 'Word1\nWord2'
end
and I'd expect the response to be :
Word1
Word2
unfortunatly I get Word1\nWord2
Any help would be appreciated
(The action must render a multiline response to get the autocomplete jquery plugin working)
...
I have a very simple task at hand. If the last time a record was updated has been longer than 15 minutes, display a button. Otherwise, don't display the button.
The field is a datetime.
My view code:
<% if @object.display_button? -%>
my button
<% end -%>
My display button method on that object:
def display_button?
return fals...
Which gem or plugin should I use for building Myspace applications using Ruby on Rails?
...
My application has the concept of a "Loan". Each loan has a creditor, a debtor, and an amount.
From a database perspective, I know that I want the loans table to look something like this:
|id|Amount|creditor_id|debtor_id|
| 1| 100| 5| 7|
Where creditor/debtor ids reference User ids (i.e., the primary key for rows in...
I know this may be a stupid question, but I don't know how to create a ruby function that accepts a hash of parameters. I mean, in Rails I'd like to use a function like this:
login_success :msg => "Success!", :gotourl => user_url
What is the prototype of a function that accepts this kind of parameters? How do I read them?
Thanks in a...
I read the Haml docs where they talk about the pre tag and "preserving whitespace". According to the docs, pre "preserves whitespace" by default and you need to use the ~ operator to output the contents of the tag to get it to render correctly. Following the recommended practice, I have this:
%pre
~ @calendar.main_template
The outpu...
If I have a statement in Ruby that I want to continue on the next line, normally I would add a backslash at the end of the line like this:
print x \
+ y
But if I have comments on the line, it doesn't work:
print x #show x
+ y # show y
Is there a way around this?
(Edit: Squeegy's solution is correct and, actually, I knew you could...
I used a backslash to continue a Ruby statement on the next line.
print abc \
+ def
I added a space after the backslash, because I like to blow things up, and, sure enough, I got an error:
unexpected $undefined, expecting $end
I assume $undefined is a global variable that means anything the compiler sees that it doesn't recognize -...
I am a ruby on rails developer and I have developed several plugins, may be i will be selling them to some web sites and they can use my plugin in there application. But i want to assure that the plugin code once given to them is not used for any other application, if they do so i must know where is it deployed.
I just need a way to tra...
I want to share (and keep updated) some base code between my rails projects with git. How can i do?
...
I am providing a web service to be called by external companies. The required data covers several models including person, address etc. I want to validate the received data conditionally based upon some fields within the request. I will eventually have many differing sets of validation data, although currently I only have one and I am ab...