Forum: Ruby on Rails update action problem

Posted by MoonFlash (Guest)
on 2010-11-13 23:23
(Received via mailing list)
Im having problem with update action in my controller when the updated
text includes word 'from'.
here is message i get:
Processing ApplicationController#index (for 78.1.131.245 at 2010-11-13
19:11:09) [GET]
  Parameters: {"commit"=>"Submit", "_method"=>"put",
"authenticity_token"=>"/rQ3EmaRkSEZpM7oCLqBGqyHV18qKJZURiLGTjSaImU=",
"page"=>{"background_id"=>"161", "content_en"=>"a London-based
architect originally from Hong Kong.", "title_en"=>"Gatehouse Room"}}

ActionController::RoutingError (No route matches "/500.shtml" with
{:method=>:get}):

If I exclude word from, i got this:
Processing PagesController#update (for 78.1.131.245 at 2010-11-13
19:16:30) [PUT]
  Parameters: {"commit"=>"Submit", "action"=>"update",
"_method"=>"put", "authenticity_token"=>"/
rQ3EmaRkSEZpM7oCLqBGqyHV18qKJZURiLGTjSaImU=", "id"=>"22",
"page"=>{"background_id"=>"161", "content_en"=>"London-based architect
originally Hong Kong.", "title_en"=>"Gatehouse Room"},
"controller"=>"pages"}
Posted by Colin Law (Guest)
on 2010-11-13 23:35
(Received via mailing list)
On 13 November 2010 18:24, MoonFlash <mladimisec@gmail.com> wrote:
> ActionController::RoutingError (No route matches "/500.shtml" with
> "controller"=>"pages"}
The first one is processing ApplicationController#index, the second
PagesController#update.  I don't think you should be processing
actions in ApplicationController.

Colin
Posted by MoonFlash (Guest)
on 2010-11-14 00:08
(Received via mailing list)
> The first one is processing ApplicationController#index, the second
> PagesController#update. I don't think you should be processing
> actions in ApplicationController.
>
> Colin
But the code is the same, the only difference is what user is entering
inside text_area.
View code:
<% form_for @page do |f| %>
  <%= f.error_messages %>
  <p>
    <div id='en' >
      <strong><%= f.label :title_en %><br /></strong>
      <%= f.text_field :title_en %><br />
      <strong><%= f.label 'Tooltip' %><br /></strong>
      <%= f.text_field :short_en %><br />
    <strong><%= f.label :content_en %></strong><br />
      <%= f.text_area :content_en%>
  </div>
<p><%= f.submit "Submit" %></p>
<%end%>
_______________________________
PagesController:
def update
    @page = Page.find(params[:id])

    if @page.update_attributes(params[:page])
      flash[:notice] = t('flash.page_edited')
      redirect_to :action =>'index'
    else
      render :action => 'edit'
    end
  end

On my localhost everything works OK.
On the server when i enter text that includes ....
select.......from... in text_area i got previous error
???
Posted by MoonFlash (Guest)
on 2010-11-14 00:15
(Received via mailing list)
It looks like, somehow, rails is processing entered text_area input as
some kind of SQL query.
Posted by Colin Law (Guest)
on 2010-11-14 09:42
(Received via mailing list)
On 13 November 2010 23:14, MoonFlash <mladimisec@gmail.com> wrote:
> It looks like, somehow, rails is processing entered text_area input as
> some kind of SQL query.

Please remember to quote the previous message so that each message
makes some sense in it's own right, otherwise we have to search back
through previous messages to work out what you are talking about.

I would concentrate on finding out why (if) it is calling the wrong
action first.  What happens after is irrelevant if it is calling the
wrong action.  No SQL or anything else is performed before the
'Processing ....' message is logged.

By the way have you actually got actions inside ApplicationController?
 This would be unusual I think.  Though I may be wrong.

Colin
Posted by Colin Law (Guest)
on 2010-11-14 10:01
(Received via mailing list)
On 13 November 2010 23:06, MoonFlash <mladimisec@gmail.com> wrote:
>
>> The first one is processing ApplicationController#index, the second
>> PagesController#update. I don't think you should be processing
>> actions in ApplicationController.
>>
>> Colin
> But the code is the same, the only difference is what user is entering
> inside text_area.

Are you sure you are interpreting the log correctly?  Have a look
before the 'processing ApplicationController#index' and check that the
submit is not there.

Colin
Posted by MoonFlash (Guest)
on 2010-11-14 16:55
(Received via mailing list)
Hi Colin, thanks for interest to help :)

In my application_controller.rb i have this:
class ApplicationController < ActionController::Base
  before_filter { |c| Authorization.current_user = c.current_user }
  before_filter :set_locale
  helper :all # include all helpers, all the time
  protect_from_forgery

  def set_locale
    I18n.locale = 'en'
  end
  include Authentication

protected

  def permission_denied
    flash[:error] = "This action is not allowed."
    redirect_to login_url
  end
end
_______________________________
 here is complete error message:
SQL (0.1ms)   SET NAMES 'utf8'
 SQL (0.1ms)   SET SQL_AUTO_IS_NULL=0
Processing ApplicationController#index (for 78.1.161.36 at 2010-11-14
16:42:36) [GET]
  Parameters: {"commit"=>"Update", "_method"=>"put",
"authenticity_token"=>"em1SzD5Y64tt9E9B3C684ToovjDNK314CdxeGQys1Hg=",
"page"=>{"background_id"=>"161", "title_fr"=>"La chambre de la
porterie", "title_de"=>"Zimmer im Portalbau", "publish_flv"=>"0",
"b_color_id"=>"4", "s_rotate_x"=>"0", "publish_as_gallery"=>"0",
"s_rotate_y"=>"0", "short_en"=>"", "publish_gallery"=>"0",
"d_rotate_x"=>"0", "hide_title"=>"1", "text_left"=>"0", "b_x"=>"0",
"d_rotate_y"=>"0", "b_y"=>"100", "short_fr"=>"", "short_de"=>"",
"content_en"=>"When selecting the furnishings for the Chateau we were
constantly struck and fascinated by the furniture and lighting designs
of famous architects. The wardrobe in this twin-bedded room is a prime
example of this formal, minimalist and ideally-proportioned designer
discourse. In addition to this wardrobe, Spencer Fung, a London-based
architect originally from Hong Kong, also designed the solid Dragon
bench in the Conference Room and the cabinets with sliding doors in
the dining room and lounge.\r\n", "publish_text"=>"1",
"scale_flv"=>"", "x_swf"=>"", "parent_id"=>"3", "y_swf"=>"",
"publish_swf"=>"0", "content_fr"=>"Lorsque nous avons choisi les
objets pour dcorer ce chteau, le mobilier et les luminaires
darchitectes de renom nont cess de nous mouvoir et de nous
fasciner. \r\n\r\nDans cette chambre aux lits jumeaux, larmoire
adhre  ce rpertoire formel sobre, minimaliste et aux proportions
idales. Spencer Fung, larchitecte londonien originaire de Hong Kong,
outre cette armoire, est reprsent au chteau par le banc massif
Dragon dans la salle de confrence et les vitrines  portes
coulissantes dans la salle  manger et le salon.", "content_de"=>"Beim
Auswhlen der Einrichtungs- gegenstnde fr dieses Chateau haben uns
immer wieder die  Entwrfe von namhaften Architekten fr Mbel und
Lampen berhrt und fasziniert. \r\n\r\nIn dieser klaren, reduzierten
und genial proportionierten Formensprache ist auch der Kleiderschrank
in diesem Schlafzimmer mit zwei getrennt nebeneinander stehenden
Betten. Spencer Fung, der Londoner Architekt aus Hongkong hat auer
diesem Kleiderschrank die schwere Sitzbank \"Dragon\" im Seminarraum
und die  Schiebetr Vitrinen im Esszimmer und im Salon gezeichnet.\r
\n", "title_en"=>"Gatehouse Room"}}

ActionController::RoutingError (No route matches "/500.shtml" with
{:method=>:get}):
  config/initializers/cgi_session_hack.rb:42:in `call'

Rendering rescues/layout (not_found)
Posted by Cesare Ferrari (cesareferrari)
on 2012-12-28 17:34
MoonFlash, I was wondering if you solved this.
I am having the same problem and can't figure it out.
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.