I have a upload text file field, and with it I plan to save the file somewhere and then store the location of the file in a database. However, I want to make sure the file they uploaded is a .txt file, and not, say, an image file. I imagine this happens in the validation step. How does one validate such a thing? Also, how do you get the ...
I normally code on windows and using MYSQL4.1. And mysql gem version is 2.8.1. In my setup when I use mysql gem to access the MYSQL server, I give the root username and password of the sql server. And in rails db config file, I give user name as 'root' and its password and host as 'localhost'. My rails server and Mysql server are running...
Hello,
I am working with Ruby on Rails projects most of the time so I need a way to save projects and the state of the buffers/windows I am working on, mostly because I often find myself switching to a different project for a few minutes and then going back to the project I was working on. Desktop.el seems to be very close except for th...
Is there a helper to avoid this sort of code?
= @leads.length == 1 ? 'is' : 'are'
I know about pluralize but it doesn't help in this case. I know that writing a helper would be trivial, I want to know if there's something in the Rails API that I have overlooked.
Thanks,
-Tim
...
i have uploaded video but when i see them in list ,, i want an image of a video ,, please help for showin image of video in list
...
Hi how to build a named_scope which will be common for all models.
...
Following are the 1-to-M models:
class FotoGossip < ActiveRecord::Base
has_many :uploads
attr_accessible :published_at, ...
end
class Upload < ActiveRecord::Base
belongs_to :foto_gossip
end
Now I want the Uploads.all with the condition :published_at NOT NULL of the corresponding upload's parent model?
...
Do I need to config.gem a gem that's already been unpacked?
...
If someone uploads an image via a form, how do you save the image in public/images and not in a model? And I do NOT want to use plugins.
...
Hi guys,
I've searched high and low, but I could not find a solution, to what I think seems like a very common task.
In a form I want to have a text input that accepts currency strings (i.e. $1,000,000 or 1000 or $12.12 and in an ideal world even 1 million)
In the database I want to keep the value as a integer.
What is the best way t...
Hi, I have a relatively simple one-to-many relationship and use acts_as_tree to get it organized in the view. It kinda looks like this:
Root
|_Product 1
|_Product 2
|_Category 1.1
|_Product 3
|_Product 4
|_Category 1.1.1
|_Product 5
The way I set it up is that I list products in the 'sh...
I want to convert the title of a page to a friendly URL and store it in the database as a permalink. My problem is I can't use the parameterize method. It's not working. Other inflections are working like upcase or downcase but parameterize is not working. Is there a special case for parameterize?
This is my code:
Controller:
def cre...
I'm writing an "action" for CloudCrowd which needs access to the Rails environment (for some ActiveRecord stuff) but the standard means of loading the environment is resulting in fishy errors.
I tried each of the following at the top of my action .rb file:
require(File.join(File.dirname(__FILE__), '../..', 'boot'))
and
require Fil...
When I run a Rails app it finds all of my installed gems correctly.
This is the first time I tried to call some gems from inside irb and it couldn't find them.
blocke:~$ irb
irb(main):001:0> require 'rubygems'
=> true
irb(main):002:0> require 'rails'
LoadError: no such file to load -- rails
from /usr/local/lib/site_ruby/1.8/rubygems/c...
My overall goal is to let users of my Rails app authenticate against our organization's ActiveDirectory server over LDAP. (Did I say that right?)
I'd like to try the Ruby ActiveLDAP gem.
The docs say it depends on either...
RubyLDAP
or...
ruby-net-ldap
Does it matter which one I use?
Am I heading in the right general direction by ...
I am facing this strange problem with the following section of code
<% if (@more == -1) %>
<%= link_to_remote "More Posts", :html => {:id => 'more-link', :onClick => 'return false;'}%>
<% else %>
<%= link_to_remote "More Posts", :url => {:action => 'view' ,:id => @more.to_i + 1} , :html => {:id => 'more-link'} %>
<% end %>
Now whe...
I'm trying to install will paginate.
I installed the gem, as detailed on the github page. The gem installed OK, but when I tried a line like
@user = User.paginate
I just got an error message about the paginate method not existing.
So, I uninstalled the gem and tried using the plugin method:
script/plugin install svn://errtheblog.co...
Is there a way with ActiveRecord to execute a custom SQL query and have it return an array of arrays where the first row is the column names and each following row is the row data? I want to execute something like:
connection.select_rows_with_headers "SELECT id, concat(first_name, ' ', last_name) as name, email FROM users"
And have i...
Hey, this should be pretty simple, but it's causing me a lot of grief! I have lots of buttons like this:
<form class="general" method="post" action="/password">
<div style="margin: 0pt; padding: 0pt; display: inline;">
<input type="hidden" value="Yg4EweyWwXO8RAF9nd3RZKNmQw8Yk+f2vefLQ/IENyg=" name="authenticity_token"/>
</div>
...
I just installed the restful authentication using this plugin and when I go to localhost:3000/login
i get this error
NameError in SessionController#new
uninitialized constant
SessionController
Any ideas? please help.
...