Thursday, November 26, 2009

Re: [Rails] Re: Ajax.Updater & Only get, put, and delete requests are allowed.

Brian,

You are running into Rails/RESTful convention. In those conventions, the
new action is a GET that returns the form for a new object. The create action
expects a POST with the data for the new object. If this is not the semantics
of your app or controller, either don't use 'map.resources' which does conform
to the Rails/RESTful way, or change your actions and routes.

So what does your 'new' action do?

Jeffrey


Quoting brianp <brian.o.pearce@gmail.com>:
> Hey Jeffery,
>
> thanks for the quick reply.
>
> I had a good feeling it was trying to make a post request.
>
> I did try changing the :method => :post but this actually chokes the
> method altogether. I get no response at all.
>
> And the other option for changing my routing I'm not sure I know how
> to do.
>
> My manage related routes are currently:
> map.resources :manage
> map.resources :manage, :collection => { :available => :get }
>
> How would I go about forcing :new to be :post ?
>
> i tried something like:
> map.resources :manage, :collection => { :new => :post } but this caues
> the sever now to run.
>
> On Nov 26, 12:57 am, "Jeffrey L. Taylor" <r...@abluz.dyndns.org>
> wrote:
> > Quoting brianp <brian.o.pea...@gmail.com>:
> >
> > > Hey everyone,
> >
> > > I'm using the Ajax tabs method/example seen at:http://actsasflinn.com/Ajax_Tabs/index.html
> >
> > > It renders partials without a problem but when I need it to render
> > > from :controller => 'manage', :action => 'new' I receive:
> >
> > > ActionController::MethodNotAllowed
> > > Only get, put, and delete requests are allowed.
> >
> > The AJAX code is making a POST request.  Change the routing to allow POSTs or
> > change the template or RJS to make a GET request (probably add ':method =>
> > :get') to parameter list.  If the action does not alter the state, use the
> > former, otherwise use the latter.  E.g., is it okay if a search engine spider
> > invokes the 'new' action?  From the name, I'd guess not.  So change the
> > routing to allow or even require POST requests.
> >
> > HTH,
> >   Jeffrey
>
> --
>
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
>
>

--

You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

[Rails] ActionView::TemplateError (can't convert ActiveRecord::Error into String)

I cannot work out why this error is appearing.

ActionView::TemplateError (can't convert ActiveRecord::Error into
String) on line #3 of app/views/button/_show_enquiry.html.erb:
1: <h1>Send us a message</h1>
2: <% remote_form_for :enquiry, :url => {:action => 'send_mail'} do |
f| %>
3: <%= error_messages_for 'enquiry', :header_message => "Please try
again!", :message => "We need you to change some items in order to
send us a message:" %>
4: <table>
5: <tr><td>Name:</td> <td><%= f.text_field :name, :size => 30
%></td></tr>
6: <tr><td>Contact tel:</td> <td><%= f.text_field :tel, :size =>
30 %></td></tr>

app/views/button/_show_enquiry.html.erb:3
app/views/button/_show_enquiry.html.erb:2
app/views/button/enquiry.rjs:1:in
`_run_rjs_app47views47button47enquiry46rjs'
app/views/button/enquiry.rjs:1:in
`_run_rjs_app47views47button47enquiry46rjs'
app/controllers/button_controller.rb:24:in `send_mail'
app/controllers/button_controller.rb:17:in `send_mail'

Here is the partial that is doing the rendering:

<h1>Send us a message</h1>
<% remote_form_for :enquiry, :url => {:action => 'send_mail'} do |f|
%>
<%= error_messages_for :enquiry, :header_message => "Please try
again!", :message => "We need you to change some items in order to
send us a message:" %>
<table>
<tr><td>Name:</td> <td><%= f.text_field :name, :size => 30
%></td></tr>
<tr><td>Contact tel:</td> <td><%= f.text_field :tel, :size => 30
%></td></tr>
<tr><td>Email Address:</td> <td><%= f.text_field :email, :size =>
30 %></td></tr>
<tr><td>Subject:</td> <td><%= f.text_field :subject, :size =>
30 %></td></tr>
<tr><td>Message:</td> <td><%= f.text_area :message, :rows
=> 8, :cols => 30 %></td></tr>
</table>
<%= submit_tag("Send") %>
<% end %>

And the partial is invoked by:

page.replace_html 'enquirybox', :partial => 'show_enquiry', :locals
=> {:enquiry => @enquiry}

in turn invoked from an ajax request from:

respond_to do |format|
format.js do
if @enquiry.save
Emailer.deliver_contact_email(@enquiry)
flash[:firstname] = @enquiry.firstname
render :action => 'thank_you'
else
render :action => 'enquiry'
end
end
format.html
end

Anyone have any ideas?

O.


The only difference from the 'norm' is that I am using the custom-err-
msg plugin.

O.

--

You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

[Rails] Using authlogic With a Model Other Than User?

Hello,

I want to implement authentication using the authlogic gem in an
application that already implements a User model that I cannot
modify. The authlogic authentication would be for something like a
new AdminUser model, completely separate from the existing User model.

Since authlogic is installed as a gem on the server (and used by other
applications), the gem code itself cannot be modified.

Any tips for where to begin/how to approach this?

thanks.

--

You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

[Rails] Re: a yield problem

thx a lot MaD.Much appreciate it, i have rated your reply with 5/5
stars :d
all my best,
radu

On Nov 24, 5:06 pm, MaD <mayer.domi...@gmail.com> wrote:
> <%= yield :layout %> outputs everything that is created with <%
> content_for :layout do %>...<% end %>.
>
> here is ryans railscast:http://railscasts.com/episodes/8-layouts-and-content-for

--

You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Re: [Rails] undefined method `paginate'

yuor must install plugin\gem (for ex.) sudo gem install wiil_paginate

2009/11/26 INDRANIL MUKHERJEE <indranil.since87@gmail.com>:
> while running my application I get this error message  undefined
> method `paginate'
> MY configuration is:
>
>
> Ruby version    1.8.6 (i386-mswin32)
> RubyGems version        1.3.5
> Rack version    1.0
> Rails version   2.3.4
> Active Record version   2.3.4
> Active Resource version 2.3.4
> Action Mailer version   2.3.4
> Active Support version  2.3.4
> Application root        C:/cart
> Environment     development
> Database adapter        mysql
> Database schema version 0
>
> plz reply
>
> --
>
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
>
>
>

--

You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

[Rails] Re: Ajax.Updater & Only get, put, and delete requests are allowed.

Hey Jeffery,

thanks for the quick reply.

I had a good feeling it was trying to make a post request.

I did try changing the :method => :post but this actually chokes the
method altogether. I get no response at all.

And the other option for changing my routing I'm not sure I know how
to do.

My manage related routes are currently:
map.resources :manage
map.resources :manage, :collection => { :available => :get }

How would I go about forcing :new to be :post ?

i tried something like:
map.resources :manage, :collection => { :new => :post } but this caues
the sever now to run.

On Nov 26, 12:57 am, "Jeffrey L. Taylor" <r...@abluz.dyndns.org>
wrote:
> Quoting brianp <brian.o.pea...@gmail.com>:
>
> > Hey everyone,
>
> > I'm using the Ajax tabs method/example seen at:http://actsasflinn.com/Ajax_Tabs/index.html
>
> > It renders partials without a problem but when I need it to render
> > from :controller => 'manage', :action => 'new' I receive:
>
> > ActionController::MethodNotAllowed
> > Only get, put, and delete requests are allowed.
>
> The AJAX code is making a POST request.  Change the routing to allow POSTs or
> change the template or RJS to make a GET request (probably add ':method =>
> :get') to parameter list.  If the action does not alter the state, use the
> former, otherwise use the latter.  E.g., is it okay if a search engine spider
> invokes the 'new' action?  From the name, I'd guess not.  So change the
> routing to allow or even require POST requests.
>
> HTH,
>   Jeffrey

--

You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

[Rails] Ajax.Updater & Only get, put, and delete requests are allowed.

Hey everyone,

I'm using the Ajax tabs method/example seen at: http://actsasflinn.com/Ajax_Tabs/index.html

It renders partials without a problem but when I need it to render
from :controller => 'manage', :action => 'new' I receive:

ActionController::MethodNotAllowed
Only get, put, and delete requests are allowed.

/Library/Ruby/Gems/1.8/gems/actionpack-2.3.2/lib/action_controller/
routing/recognition_optimisation.rb:64:in `recognize_path'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.2/lib/action_controller/
routing/route_set.rb:437:in `recognize'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.2/lib/action_controller/
routing/route_set.rb:432:in `call'

running rake routes I can see:
GET /manage/new(.:format)
{:controller=>"manage", :action=>"new"}

and if I access the page on it's own (root/manage/new) everything
works fine.

Any recommendations on how to get the desired content loaded?

thanks,
bp

--

You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.