In routes.rb (for preview & publish), use :any instead of :post, might work.


Thanks,
Abhinav
--
अभिनव
http://twitter.com/abhinav



On Thu, Sep 24, 2009 at 2:45 PM, nisha <[email protected]> wrote:

>
> Hi,
>
> Iam getting the following error
>
> ActionController::MethodNotAllowed
> Only get, put and delete requests are allowed.
>
> Actually, Iam trying to have multiple actions for a  form to create
> new record. The actions for the form are cancel, save, publish and
> preview.
>
> here's the config/routes.rb file code snippet for the relevant
> controller - Events
>
> map.resources :events, :member => {:manage => :get}, :new => {:preview
> => :post, :publilsh => :post}
>
> The EventsController has functions for new, create, edit, update,
> manage, preview and publish.
>
> the new.html.erb snippet is
>
> <% form_for  @event, :url => events_path, :html => {:multipart =>
> true, :id => "event_form"} do |f| -%>
>        <%= render :partial => "form", :locals => {:f => f} %>
>        <%= link_to image_tag("/images/btn-cancel.png", :border => 0),
> dashboard_path, :style => "float:left;" %>
>        <%= link_to_function image_tag("/images/btn-publish.png", :border =>
> 0), "publish_event($(this));", :style => "padding-right:20px;" %>
>        <%= link_to_function image_tag("/images/btn-preview.png", :border =>
> 0), "preview_event($(this));", :style => "padding-right:20px;" %>
>        <input type="image" src="/images/btn-save-draft.png" name="save"
> value="Save" class="image_input"></input>
> <% end -%>
>
> the javascript functions in application.js
>
> function preview_event(element){
>        element.up('#event_form').writeAttribute('target', '_blank');
>        element.up('#event_form').action = "preview";
>        element.up('#event_form').method = "post";
>        element.up('#event_form').submit();
>        element.up('#event_form').writeAttribute('target', false);
> }
>
> function publish_event(element) {
>        element.up('#event_form').action = "publish";
>        element.up('#event_form').method = "post";
>        element.up('#event_form').submit();
>    }
>
>
> Iam stuck with the error. Pls help
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to