ruby-on-rails

getting "Permission denied: No matching rules found for..." using declarative_authorization

Hi, Just starting out, but getting: Processing WebfileController#new (for 10.1.1.1 at 2009-12-14 09:45:14) [GET] Parameters: {"action"=>"new", "controller"=>"webfile"} User Columns (2.0ms) SHOW FIELDS FROM `users` User Indexes (0.3ms) SHOW KEYS FROM `users` Permission denied: No matching rules found for create for #<Authoriza...

Autocomplete with Vim and Rails Datamapper

Is there a way that I can have auto completion in Vim after I load a model from the database? So for example if I have a model of type Foo with an instance method of type bar and do the following foo = Foo.first(:param=>'x') foo.b should show me bar as a possible auto complete value. I think that this is somewhat hard to accomplish wi...

trying to find duplicate usernames in ruby

hi i am trying to ensure that the username is unique when registering but im not sure how to do this I've tried: validates_uniqueness_of :username but it doesnt work it gives me this error: undefined method 'validates_uniqueness_of' for #<UsersController:0x6c4fd2> Any help please? ...

Ruby: Seaching a hash for something

I'm using the Highrise API and Ruby wrapper, but my problem is that (besides having a nightmare of a time with the API it self) I want to search a hash that is returned for something: >> Highrise::Person.find(:all).detect{|p| p.name == 'Brandon'} => [#<Highrise::Person:0x102a4d2f8 @prefix_options={}, @attri.... I can do that but obvio...

Rails foreign key is nil in nested form

I have a couple models (Site and Server) that are related to eachother via has_many :through. they also both belong_to :user. in my sites/new view, I create a new site, and I create a new server using a nested form.fields_for :servers. Everything works as expected, except for that the server that ends up getting created doesn't have a ...

RoR - Closing form_tag

How do I close a form_tag? Here's my code: <%= form_tag :action => 'authenticate' %> <h1>Already a member?</h1> <table> <tr> <td>Username*: </td> <td><%= text_field("userform", "user_name", :size => "20", :class => "field") %></td> </tr> <tr> <td>Password*: </td> <td><%= password_field("userform", "password", :size...

gem being loaded by script/console initialization, but not server initialization

I'm moving a rails app from my desktop to a shared host, and I'm running into trouble with a gem dependency. I have this declared in my environment.rb: config.gem "icalendar" When I first tried starting a console for the app, I got error messages requesting that I rake:install the gem. I used the shared hosting gem install process t...

pass parameter by link_to ruby on rails

Hi I have this line of code: <%= link_to "Add to cart", :controller => "car", :action => "add_to_cart", :car => car %> when im in the add_to_cart method...how can i call the :car please? @car = Car.new(params[:car]) doesnt work because it says im trying to stringify I dont understand whats wrong because I used this to create new ...

Prevent Rails test from deleting seed data

I am using seeds.rb to populate some State model reference data: State.create :name => 'Alabama', :abbreviation => 'AL' State.create :name => 'Alaska', :abbreviation => 'AK' # ... Although I am not using state fixtures (since it's seed data to begin with, I think it wouldn't be DRY to have to duplicate this purely for tests), the Rail...

Can any of the rails wysiwyg plugins easily submit all images to a controller rather than a file upload path?

I've tried ckeditor and fckeditor plugins, and while easy-fckeditor works rather nicely, it drops my files in a common directory. If I have overloaded image names or versions, they get clobbered. FCKEditor is great at the present time, but I'll would prefer to be able to capture the image upload into a controller, similar to paperclip,...

shopping cart ruby on rails

hi im using def add_to_cart @cart = find_cart product = Product.find(params[:id]) @cart.add_product(product) end from a book. this is to create a shopping cart. what I don't understand is, do I need a controller for my cart? because without it,its giving me an error ...

How to show string in xml format in erb file

Hi, In the controller, I have an variable @xml_string = "<tag> hello \n world </tag>". Now I want to show the content of @xml_string. In erb file I wrote <%= @xml_string %>, but this can only display hello world, the xml tag <tag> </tag> was missed and \n was ignored. Aslo , <% render :text => @xml_string , :content_type = 'applicat...

Why are tests running in production mode and causing my script/runners to fail?

So I have some script/runners set up in a cron job, but according to the logs, I'm getting this error below. First, I'm not sure why Test::Unit automatic runner is happening in production to begin with. I don't have autospec or autotest going on. Secondly, I'm not sure how to resolve this pesky invalid option error. I'm using the java...

Set the form width and height for form_for in Rails

Hi, Is there is any way to specify the width and height of a form when using form_for? Thanks. ...

Can I scope dynamic attribute-based finders to an object?

Don't mind me, I fricked up my attribute names :( This is entirely possible, using the exact syntax I used - you just need to be able to spell! I can't seem to get this to work, and it seems like a common enough scenario that there must be a solution, but I'm not having any luck with the correct terminology to get a helpful Google re...

Determine if script/server is being started

In Rails, in an initializer/environment.rb Whats the pefered way to detemrine if the webapp itself is being loaded (script/server). All the initializers are loaded for migrations script/console and other rails task as well, but in my case some stuff only has to be loaded when the server itself is being initialized. My ideas: checking ...

Problem saving time in rails.

I have an application which save datetime using Time.now, but when I retrieves it and compare with Time.now again it not the same format and result in unexpected result. What should I do to always make this time standard all the time. Thanks, ...

Multi-page record creation

puts 'newbie question' I have an account sign-up that spans multiple pages, but I'm not exactly wrapping my head around creating a new instance that is tied to a database but only adds to the database if all pages are completed. I have three actions: def index @ticket = Ticket.new end def signup_a end def signup_b end The index pa...

What is a good PDF to HTML converter for Ruby on Rails?

I'm trying to convert programatically PDF to HTML. So far I've been using pdftohtml but our users are not happy with the results. Here's what I need : I'm using Ruby on Rails, but any tool working on Unix would work as I can call it from the command line. But of course a nice gem or plugin would be perfect. I'd prefer it to be open s...

Understanding Rails Unit Testing: Is it still a unit test if a single test tests model interdependencies?

Besides the fact that Rails incorporates the database layer into the unit tests (which then is strictly not a unit test), what if I test for model interdependencies, e.g. check if has_many/belongs_to with :dependent => :destroy really destroys the associated items or items from join models to not leave orphans around? Should such a test...