controller

CodeIgniter - Remove “Index” From URL

為{幸葍}努か 提交于 2019-12-18 08:02:09
问题 NOTE: I'm not talking about removing index.php - I mean index - the method name. My current URL looks like this: www.mysite.com/view-topic/index/my-topic This is what I want it to look like: wwww.mysite.com/view-topic/my-topic How would I go about doing this? Thanks in advance! 回答1: You can set up the routes for this, in application/config/routes.php , add a new line: $route['view-topic/(:any)'] = 'view-topic/index/$1'; This will route your URL http://url.com/view-topic/anythinggoeshere will

CodeIgniter - Remove “Index” From URL

你离开我真会死。 提交于 2019-12-18 08:01:09
问题 NOTE: I'm not talking about removing index.php - I mean index - the method name. My current URL looks like this: www.mysite.com/view-topic/index/my-topic This is what I want it to look like: wwww.mysite.com/view-topic/my-topic How would I go about doing this? Thanks in advance! 回答1: You can set up the routes for this, in application/config/routes.php , add a new line: $route['view-topic/(:any)'] = 'view-topic/index/$1'; This will route your URL http://url.com/view-topic/anythinggoeshere will

How to access a JavaFx Stage from a Controller?

戏子无情 提交于 2019-12-18 05:56:32
问题 I'm converting a pure JavaFx app, in which the code below worked fine when put all in one class, to a FXML one, where the Stage declaration and the button handler are in separate classes. In the a Controller, I'm trying to implement a method that will allow the user to choose a directory and store it in a variable for later use: private File sourceFile; DirectoryChooser sourceDirectoryChooser; @FXML private void handleSourceBrowse() { sourceDirectoryChooser.setTitle("Choose the source folder"

How to access parent member controller from child controller

核能气质少年 提交于 2019-12-18 05:06:16
问题 This question is similar to this, but I need to access parent member (not control). I don't know if is possible to do without using Dependency Injection. For example, I have a Parent with have a member calls User, I need to access from child controller to User. 回答1: Just pass the reference from the parent controller to the child controller in the parent controller's initialize() method: ParentController.java: public class ParentController { @FXML private ChildController childController ;

How can I avoid AmbiguousMatchException between two controller actions?

早过忘川 提交于 2019-12-18 04:39:13
问题 I have two controller actions with the same name but with different method signatures. They look like this: // // GET: /Stationery/5?asHtml=true [AcceptVerbs(HttpVerbs.Get)] public ContentResult Show(int id, bool asHtml) { if (!asHtml) RedirectToAction("Show", id); var result = Stationery.Load(id); return Content(result.GetHtml()); } // // GET: /Stationery/5 [AcceptVerbs(HttpVerbs.Get)] public XmlResult Show(int id) { var result = Stationery.Load(id); return new XmlResult(result); } My unit

Rspec: Controller specs for 2 level nested resources

拈花ヽ惹草 提交于 2019-12-18 04:32:34
问题 my routes.rb namespace :magazine do resources :pages do resources :articles do resources :comments end end end While writing controller specs for Comments: describe "GET 'index'" do before(:each) do @user = FactoryGirl.create(:user) @page = FactoryGirl.build(:page) @page.creator = @user @page.save @article = FactoryGirl.create(:article) @comment_attributes = FactoryGirl.attributes_for(:comment, :article_id => @article ) end it "populates an array of materials" do get :index, ?? #response

Rspec: Controller specs for 2 level nested resources

守給你的承諾、 提交于 2019-12-18 04:31:28
问题 my routes.rb namespace :magazine do resources :pages do resources :articles do resources :comments end end end While writing controller specs for Comments: describe "GET 'index'" do before(:each) do @user = FactoryGirl.create(:user) @page = FactoryGirl.build(:page) @page.creator = @user @page.save @article = FactoryGirl.create(:article) @comment_attributes = FactoryGirl.attributes_for(:comment, :article_id => @article ) end it "populates an array of materials" do get :index, ?? #response

Select checkbox pass array in ruby on rails

别说谁变了你拦得住时间么 提交于 2019-12-18 04:23:38
问题 How can I pass the value of array? of the selected checkbox. In View: = check_box_tag 'user_message_ids[]', user_message.id, false = link_to "<button>Bulk Delete</button>".html_safe, profile_message_path(user_message), :id => 'user_message_ids', :confirm => "Are you sure?", :method => :delete and can I place the submit button in any of this area. like this one: = form_tag checked_messages_path do = check_box_tag 'user_message_ids[]', user_message.id, false --------objects---------------------

CakePHP 2.3.8: Calling Another Controller function in CronController.php

百般思念 提交于 2019-12-18 04:15:22
问题 For CakePHP 2.3.8 How can I call Another Controller function in CronController.php Any ideas? 回答1: Below is the code: App::import('Controller', 'Products'); // mention at top // Instantiation // mention within cron function $Products = new ProductsController; // Call a method from $Products->ControllerFunction(); Hope it helps some one ! 回答2: Use the $this->requestAction(); method in your controller action. It's not the most recommended pattern, but it can be useful and can return data or

How to write an action filter for all controllers

大城市里の小女人 提交于 2019-12-18 04:08:20
问题 Here is a sample action filter. We know that when we write an action filter then we need to decorate the controller with an attribute like this, to use it for any controller. I like to know whether there is any way to write an action filter which will work for all controllers in way that I do not need to decorate all the controllers with an action filter attribute. Any ideas? [LogActionFilter] public class HomeController : Controller {} public class LogActionFilter : ActionFilterAttribute {