routing

Rails 4 - explicit model name for resource id route

耗尽温柔 提交于 2019-12-06 11:56:15
When defining the following route in routes.rb : resources :streams Rails generates the following urls: streams GET /streams(.:format) POST /streams(.:format) new_stream GET /streams/new(.:format) edit_stream GET /streams/:id/edit(.:format) stream GET /streams/:id(.:format) PATCH /streams/:id(.:format) PUT /streams/:id(.:format) DELETE /streams/:id(.:format) I would like to have an explicit resource id, i.e. :stream_id instead of :id . edit: For simple resources the solution is like @user2262149 and @vimsha mentioned: resources :streams, :param => :stream_id The problem is with nested

Devise and I18n - reset password routing issues

此生再无相见时 提交于 2019-12-06 11:48:47
问题 I added I18n to my RoR app that is using Devise and I am now getting an error if I try to do a password reset. The error is: Routing Error No route matches {:action=>"edit", :controller=>"devise/passwords", :reset_password_token=>"uMopWesaxczNn2cdePUQ"} How can I correctly set up my Devise routing to account for I18n? routes.rb scope ":locale", locale: /#{I18n.available_locales.join("|")}/ do devise_for :users, path_names: {sign_in: "login", sign_out: "logout"}, controllers: {omniauth

“resources :post, except: :new” makes Rails think the route /posts/new would point to a post ID “new”

删除回忆录丶 提交于 2019-12-06 11:17:14
问题 I have the following route: resources :success_criteria, except: :new The following spec fails: describe SuccessCriteriaController do describe 'routing' do it 'routes to #new' do expect(get('/success_criteria/new')).to_not be_routable end end end Failure message: Failure/Error: expect(get('/posts/new')).to_not be_routable expected {:get=>"/posts/new"} not to be routable, but it routes to {:controller=>"posts", :action=>"show", :id=>"new"} The controller looks like this: class

Laravel Authentication for multiple users

做~自己de王妃 提交于 2019-12-06 10:47:25
I have 4 types of users in my application and details are stored in 4 different tables, so how can I implement Laravel's Authentication? Route::post('/adlogin', 'mainController@adminlogin'); Route::get('/sellerlogin', function () { return view('seller.pages.login'); }); Route::post('/sellerlog_in', 'mainController@sellerlogin'); Use this as your controller <?php namespace App\Http\Controllers\Auth; use Illuminate\Http\Request; use App\Http\Controllers\Controller; //Use Dependencies use Auth; class AdminLoginController extends Controller { Middleware used here is admin which you have to create

Can have part of the domain name as a parameter in my routing rules?

余生颓废 提交于 2019-12-06 10:00:23
问题 I'd like to have a routing rule that accepted part of my domain name as a parameter. For example: {name}.mydomain.com/photos/{id} Is this even possible? 回答1: I have had a similar issue in using asp.net mvc, but with using the whole domain instead of just the subdomain. What we used was a custom route constraint to determine which controller to go to (domain determined controller on our project). Then in the controller we used the normal asp.net request.url properties to take an action. This

Pretty Paths in Rails

本小妞迷上赌 提交于 2019-12-06 09:35:43
问题 I have a category model and I'm routing it using the default scaffolding of resources :categories . I'm wondering if there's a way to change the paths from /category/:id to /category/:name . I added: match "/categories/:name" => "categories#show" above the resources line in routes.rb and changed the show action in the controller to do: @category = Category.find_by_name(params[:name]) it works, but the 'magic paths' such as link_to some_category still use the :id format. Is there a way to do

Angular route parameters contraints

让人想犯罪 __ 提交于 2019-12-06 09:19:09
问题 I'm coming from the Asp.net MVC world where route constraints are really useful. I'm currently developing an Angular JS SPA that incorporates client side routing. I would also like to add parameter constraints to my client-side routes as in: $.routeProvider.when("/post/:id/:name?") where I'd like to constrain my :id parameter to only be valid when these are numbers. I haven't found anything similar in Angular Docs (which are horrible to say the least). Can it be done? And maybe also parameter

Iron-router nested routes with multiple parameters

大兔子大兔子 提交于 2019-12-06 09:06:34
问题 I have two models: sites and articles . Each site can have multiple articles. I would like to view the article in the route like this: /siteName/articleFriendlyTitleUrl . At the moment I have helper method to make friendly urls like this: getFriendlyUrl = function(urlString){ urlString = urlString.toLowerCase(); urlString = str.replace(/[^a-z0-9\s]/gi, '').replace(/[_\s]/g, '-'); return urlString; } And my router.js file: this.route('showArticle', { path: '/article/:title'), layoutTemplate:

routes.MapPageRoute does not work with point?

强颜欢笑 提交于 2019-12-06 08:54:10
I am using asp.net webform. In my application, I show user page like http://localhost/username In RouteConfig.cs I register routes like this: routes.MapPageRoute("default", "", "~/default.aspx"); routes.MapPageRoute("user", "{id}", "~/user.aspx"); routes.MapPageRoute("search", "search/{id}", "~/search.aspx"); but when a username contains point (.) it shows 404 error. http://locahost/name.lastname this shows error. Any hint? Thanks Yigit I thought it was related with extensions. So, I found an answer about this. ASP.NET Webforms routing with extension I add this to web.config <modules

Spring Integration - writing to a error queue when Exception happended in a Service Activator component

我的未来我决定 提交于 2019-12-06 08:44:40
问题 I'm starting to use Spring integration and I don't know how to resolve this situation if it's possible. I would like to 'catch' automatically every Exception who could happend in the service activators of my application and send this errors to a dedicated queue. Gateway is not a solution because I need some custom code so I have to use service activator elements if I have correctly understood the principle. I thought that something like would be ok: <jms:outbound-channel-adapter channel=