routes

Nested URLs, controllers and views in Ruby on Rails

主宰稳场 提交于 2019-12-25 08:46:47
问题 What I am trying to do is to nest my pages in Rails for example: www.mysite.com/fifa17/ps4 This way, once I am on the show.html.erb , I can use use the route to sell my product for specifically that game on that console platform.. At the moment, I have a Console model with has_many :games and a Game model with has_many :consoles , but I can't get the routing and views to work. Do I have just one controller or two? I have both the Games and Consoles seeded under ActiveRecords by name . I seem

Laravel routes going to wrong route

橙三吉。 提交于 2019-12-25 08:24:47
问题 I do not understand the following problem. Here are me routes: Route::get('events', array('as' => 'events' ,'uses' => 'EventController@index')); Route::get('event/{id}', array('as' => 'event' ,'uses' => 'EventController@view')); Route::get('event/new_event', array('as'=> 'new_event', 'uses' => 'EventController@newEvent')); Route::post('event/create', array('uses' => 'EventController@create')); Route::get('event/{id}/edit', array('as' => 'edit_event', 'uses' => 'EventController@edit')); Route:

Rails routing using custom attribute rather than table column

懵懂的女人 提交于 2019-12-25 08:02:37
问题 Using Rails 4.2, I want to create a custom route using an attr_accessor rather than a table column, but I can't get the resource_path method to work. I want custom route like this: /foos/the-title-parameterized-1 (where " 1 " is the id of the object). Foo model: #... attr_accessor :slug #dynamically generate a slug: def slug "#{self.title.parameterize[0..200]}-#{self.id}" end #... routes.rb : get 'foos/:slug' => 'foos#show', :as => 'foo' foos_controller.rb : def show @foo = Foo.find params[

Direct route to custom search with MVC

前提是你 提交于 2019-12-25 07:25:07
问题 I need to create a custom route with MVC to build a custom search: Default Home's Index's Action: public virtual ActionResult Index() { return View(); } And I would like to read a string like this: public virtual ActionResult Index(string name) { // call a service with the string name return View(); } For an URL like: www.company.com/name The problem is that I have this two routes but it's not working: routes.MapRoute( name: "Name", url: "{name}", defaults: new { controller = "Home", action =

rails namespace routes and controller

雨燕双飞 提交于 2019-12-25 05:46:08
问题 i just can not figure out the best way to handle the routes / controller with the following namespace. i´d just like to have the following setup: .../manage/rooms/ ( <%= @ rooms.number_of_rooms%>, <%= @ rooms.title %> ) .../manage/fuu/ ( <%= @ fuu.id %>...) ..manage/foo/ ... i know this is done by routes.rb namespace :manage do resources :rooms, :fuu, :foo end and under ... controller/manage/rooms_controller.rb and fuu_controller.rb and foo... example: class Manage::RoomsController <

Cannot access POST route in Laravel via browser

亡梦爱人 提交于 2019-12-25 05:24:10
问题 Using Laravel 5.4 have this route in web.php Route::post('foo/bar', function () { return 'Hello World'; }); but when I visit the http://localhost:8000/foo/bar URL in browser I have this error: MethodNotAllowedHttpException in RouteCollection.php line 251: in RouteCollection.php line 251 at RouteCollection->methodNotAllowed(array('POST')) in RouteCollection.php line 238 at RouteCollection->getRouteForMethods(object(Request), array('POST')) in RouteCollection.php line 176 at RouteCollection-

Routes with multiple arguments in ASP.NET MVC 3

狂风中的少年 提交于 2019-12-25 04:44:44
问题 I am trying to set up dynamic routes in an MVC app, and I have this so far... string conString = "YATAYATAYATA"; SqlConnection con = new SqlConnection(conString); SqlCommand cmd = new SqlCommand(); // Retrieve routes from database cmd.CommandText = "SELECT R.*,S.* FROM Routes R INNER JOIN Sites S ON S.ID = R.SiteID WHERE S.ID = 1"; cmd.CommandType = CommandType.Text; cmd.Connection = con; con.Open(); SqlDataReader rdr = cmd.ExecuteReader(); while (rdr.Read()) { routes.MapRoute( rdr["name"]

how to access activemq jms custom header property; from camel route

≯℡__Kan透↙ 提交于 2019-12-25 04:42:45
问题 Please see this question first. How can I access that custom header property value from "queue2"?outside of that route builder method or class. I am using something like shown below. I dont find any methods in consumerTemplate API to get custom header properties. ConsumerTemplate consumerTemplate = camelContext.createConsumerTemplate(); textMessage = consumerTemplate.receiveBody("activemq:queue2",10000,String.class); that question is to set header using camel route. but this question about

Rails 4 error - rails Couldn't find User with 'id'=index

我与影子孤独终老i 提交于 2019-12-25 04:01:31
问题 I am trying to make an app in Rails 4. I'm trying to follow CyberDude's advice in this post: Defining Roles with Rolify I'm getting stuck at the part where I make an index for users in the user/views file. I am getting an error that says: ActiveRecord::RecordNotFound in UsersController#show Couldn't find User with 'id'=index Extracted source (around line #69): 67 68 69 70 71 72 private def set_user @user = User.find(params[:id]) end def user_params I can't understand this error message.

Zend Route incorrect relative path

爱⌒轻易说出口 提交于 2019-12-25 03:37:29
问题 My routes work fine apart from when I am at an action that requires a parameter. For example, these work ok: /news /news/admin /news/admin/add But this doesn't: /news/admin/edit/1 But only routes using the 'default' route render incorrectly (they render as ../../module/controller), all other routes render correctly (/module/conntroller) Any ideas why, or how to fix it? 回答1: It's a common problem. If you are using custom routes in your navigation you must explicitly pass 'default' route to