routes

Rails namescoped model object without module prefix route path

心不动则不痛 提交于 2019-12-11 05:50:03
问题 i have problem little bit with Rails router and form generator. My application have namespaced modules for models and controllers. Module is used to easier abstraction to another projects. I using in routes.rb scope method instead namespace, because i wan't have "ugly" path helpers. It looks like: scope module: :taxonomy do resources :taxonomies do resources :terms end end Problem is that when i want to edit taxonomy (url: taxonomies/1/edit ) i get an error: undefined method `taxonomy

Add a prefix to generated links, but not to incoming routes

倾然丶 夕夏残阳落幕 提交于 2019-12-11 05:47:07
问题 Our Rails 4 application needs to be accessible over an archaic portal. This portal works by adding (from the perspective of the browser) a prefix to each URL; this prefix is removed by the portal before forwarding the request to my application. So the browser calls https://portal.company.com/portal/prefix/xyzzy/myapp/mymodel/new ; the portal does its thing and requests https://myserver.company.com/myapp/mymodel/new (passing along the stripped prefix in some irrelevant way). The prefix is

Kohana redirect

半世苍凉 提交于 2019-12-11 05:05:17
问题 After a form-submit in Kohana, I want the user to go back to the homepage. Is it correct to use a redirect for this? public function action_edit($id) { if (!empty($post)) { if ($post->validate()) { $this->request->redirect(Route::get('admin')->uri(array('action' => 'list'))); } } } Thanks in advance! 回答1: Sometimes $this->request->uri($params) (instead of Route::get()->uri() ) maybe useful. For example, when you want to use current controller (redirect to another action) or the same route. It

Extra directory prepended to my routes in production

无人久伴 提交于 2019-12-11 05:05:10
问题 My rails application works fine locally, and seems to deploy normally. The root route brings you to my welcome splash page. I have a link on that page to the index for my organizations model, generated by the following code: <%= link_to("Organizations", organizations_path, :class => "button_blue") %> When I try to click that link on the production server, hosted by a2 hosting, I get the following error: Started GET "/database/organizations.shtml" for 11.222.33.444 at Sat Oct 05 00:10:35 -0400

How to return an html modal target view from server?

北城余情 提交于 2019-12-11 05:01:17
问题 I want to have a button on the website that opens up a modal view using bootstrap. Like so: <button class="btn btn-primary btn-lg" id="modalButton" data-toggle="modal" data-target="#myModal"> Launch demo modal </button> So this button is targeting a view called #myModal. Instead of loading the #myModal view from the client html, I want to make an AJAX request to the server to get #myModal view because the view will be different depending on if the user is admin or not, and that variable

DEPRECATION WARNING: Using a dynamic :controller segment in a route is deprecated and will be removed in Rails 5.1

旧巷老猫 提交于 2019-12-11 04:55:37
问题 I have config/routes.rb with warning DEPRECATION WARNING: Using a dynamic :controller segment in a route is deprecated and will be removed in Rails 5.1. Don't know how to rewrite to remove the warning. Any document to understand how todo. Or new code Thx. Rails.application.routes.draw do post ':controller(/:action(/:id))(.:format)' get ':controller(/:action(/:id))(.:format)' get '/logout' => 'sessions#destroy', :as => 'logout' get '/auth/failure' => 'sessions#failure' post '/auth/:provider

Rails 3, comments in a nested form, wrong routes?

北城以北 提交于 2019-12-11 04:47:12
问题 I have a Posts model, which has many posts in many languages . It's a bit non-standard, but to illustrate: class Post < ActiveRecord::Base has_one :eng_post, :dependent => :destroy # <-- HAS_ONE! accepts_nested_attributes_for :eng_post, :allow_destroy => true end I.e. a Post has one EngPost. Whereas EngPost is defined in the model as: class EngPost < ActiveRecord::Base belongs_to :post has_many :eng_comments, :dependent => :destroy accepts_nested_attributes_for :eng_comments, :allow_destroy =

How to add custom routes to Symfony 2 before container compilation?

前提是你 提交于 2019-12-11 04:32:49
问题 Let me explain the case in further details because the title doesn't explain it very well without being too long. I'm building a mini framework on top of SF2 to use with our legacy system. We developed a mini, simple plugin system, each plugin will have its own routing.xml which may look like this: routes: admin_plugins: pattern: /manager/ defaults: { _controller: plugins\riCore\AdminController::indexAction } We want to obviously add these routes into the routeCollection, but there is 1 tweak

Netlogo: How using the route variable to actually move along the path

a 夏天 提交于 2019-12-11 04:25:55
问题 I use two types of turtles, cars and houses. both are randomly positioned. My goal is to get a route for each car starting from a combined route vector, and have each car move and visit every home that has been assigned to it. First i create a route for each car from the combined route vector. I present my code below. But now, im trying make car follow respective route... globals [ route-vector ] breed [carr car] breed [hous housess] carr-own [ route ] to setup clear-all create-carros create

Rails routes based on current user

大憨熊 提交于 2019-12-11 04:17:45
问题 I followed this rails cast to create authentication for a rails project. My routes currently look like this: Rails.application.routes.draw do resources :messages get "log_out" => "sessions#destroy", :as => "log_out" get "log_in" => "sessions#new", :as => "log_in" get "sign_up" => "users#new", :as => "sign_up" get "new_photo" => "users#edit", :as => "new_photo" root :to => "users#new" resources :users resources :sessions end How to I edit this file so that the root will be pointing to