Hello I'm trying to call a function that I wrote on my controller from my javascript as result of an action when I click on a button.
I followed that thread but it's not worked at all. When I click on the button I get the error listed bellow:
Started GET "/projects/:id/repository/:branch" for 127.0.0.1 at 2013-11-29 15:03:43 -0200
Processing by RepositoriesController#show as */*
Parameters: {"id"=>":id", "repository_id"=>":branch"}
←[1m←[35m (0.0ms)←[0m SELECT MAX(`settings`.`updated_on`) AS max_id FROM `settings`
←[1m←[36mUser Load (0.0ms)←[0m ←[1mSELECT `users`.* FROM `users` WHERE `users`.`type` IN ('User', 'AnonymousUser') AND `users`.`status` = 1 AND `users`.`
id` = 10 LIMIT 1←[0m
Current user: guilherme.noronha (id=10)
←[1m←[35mProject Load (1.0ms)←[0m SELECT `projects`.* FROM `projects` WHERE `projects`.`identifier` = ':id' LIMIT 1
Rendered common/error.html.erb (1.0ms)
Filter chain halted as :find_project_repository rendered or redirected
Completed 404 Not Found in 24ms (Views: 21.0ms | ActiveRecord: 1.0ms)
I didn't understand well why I get this error, so I'm here to ask for help.
Bellow my code to try to detect some mistake or absence of something:
_view_button_release.html.erb
<script>
function CallExec(rep) {
$.ajax("/projects/:id/repository/:branch");
}
</script>
<div class="contextual">
<% if User.current.allowed_to?(:exec, @project) %>
<%= button_to_function l(:gerar_build_project), 'CallExec("'+params[:repository_id].to_s+'")' %>
|
<% end %>
</div>
routes.rb
resources :repositories do
match 'projects/:id/repository', :action => 'exec_client', :controller => 'repositories', :via => :post
match 'projects/:id/repository/:branch', :action => 'exec_client', :controller => 'repositories', :via => :post
get :exec_client, on: :collection
end
client.rb (hook)
module InstanceMethods
require_dependency 'repositories_controller'
def exec_client
begin
...
end
end
end
Any suggestion?
UPDATE:
New Log
Started GET "/projects/b1309/repository/b1309i11/" for 127.0.0.1 at 2013-12-02 10:38:00 -0200
Processing by RepositoriesController#show as */*
Parameters: {"id"=>"b1309", "repository_id"=>"b1309i11"}
←[1m←[35m (0.0ms)←[0m SELECT MAX(`settings`.`updated_on`) AS max_id FROM `settings`
←[1m←[36mUser Load (0.0ms)←[0m ←[1mSELECT `users`.* FROM `users` WHERE `users`.`type` IN ('User', 'AnonymousUser') AND `users`.`status` = 1 AND `users`.`
id` = 10 LIMIT 1←[0m
Current user: guilherme.noronha (id=10)