controllers

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

Loading angular js internal routes and controllers

好久不见. 提交于 2019-12-25 04:26:28
问题 I have an issue with the routes and controller. If I have a route like below this-> .state('dashboard/profile', { url: '/dashboard/profile', parent: 'common', //templateUrl: '/app/dashboard/dashboard.html', template: '<div><h4>dashboard/profile</h4></div>', controller: 'ProfileCtrl' }) Now as I will be having many routes,I want to load all the routes inside dashboard only after the user reaches dashboard.html page.If I follow as above I will have to load all the routes even when not needed

Best practice to update parent or other simultaneous Angular controllers?

十年热恋 提交于 2019-12-24 21:47:36
问题 Forgive if this is general, but I'm looking for an approach and I'm new to Angular. Say I have a main controller and a runtime created modal controller. Let them be WidgetCtrl and NewWidgetModalCtrl. I want to create a Widget and send that data to the server using $resource.save() . It returns some data and we close the "New Widget Modal" (it gets $destroyed). How would I add this widget to the list in WidgetCtrl? Some say to use a shared service/factory. But the problem is that these are

Testing a controller not using $scope using karma

試著忘記壹切 提交于 2019-12-24 11:28:13
问题 I followed the instructions on docs.angularjs.org to test a controller with karma and it's perfectly working. However I was wondering if it's possible to test a controller which is not using $scope? Testing this controller is ok: angular.module('starter.controllers') .controller('PasswordController', function PasswordController($scope) { $scope.password = ''; $scope.grade = function() { var size = $scope.password.length; if (size > 8) { $scope.strength = 'strong'; } else if (size > 3) {

LARAVEL - Displaying images from the storage folder

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-23 21:45:10
问题 I'm new to Laravel and was wondering if someone can help me out with a simple image upload. I have a form that allows a user to create a profile and upload and avatar for their profile during the process. This all works perfectly. Here is the code from my controller: if (request()->hasFile('avatar')) { $file = request()->file('avatar'); $file->storeAs('avatars/' . auth()->id(), 'avatar.jpg'); } The image is saved within storage/app/avatars/USER-ID/avatar.jpg I'm not sure how to display the

Rails 3.2.3 namespaced controllers being overridden by global controllers with same name

为君一笑 提交于 2019-12-23 08:29:12
问题 When the global application controller is loaded first, the namespaced application controller does not load when loading pages within that namespace. The application controller looks like this: class ApplicationController < ActionController::Base protect_from_forgery end And the namespaced application controller looks like this: class Admin::ApplicationController < ApplicationController def authenticate_admin! if current_admin.nil? redirect_to new_admin_session_url end end private def current

Rails 3.2.3 namespaced controllers being overridden by global controllers with same name

不想你离开。 提交于 2019-12-23 08:28:20
问题 When the global application controller is loaded first, the namespaced application controller does not load when loading pages within that namespace. The application controller looks like this: class ApplicationController < ActionController::Base protect_from_forgery end And the namespaced application controller looks like this: class Admin::ApplicationController < ApplicationController def authenticate_admin! if current_admin.nil? redirect_to new_admin_session_url end end private def current

Rails Updating Data in one Model from another Model's Controller

◇◆丶佛笑我妖孽 提交于 2019-12-21 06:27:00
问题 I have a User model that has billing_id. I have Order model that runs transactions with a payment gateway which returns a billing id I'd like to save into the billing_id column on the User model. I think I am getting the basics of MVC architecture mixed up. I am under the impression that UsersController and OrdersController update data of their respective tables. Does that mean that if I have something returned from OrdersController such as a billing id, there is no other way of saving that

angularjs multiple controllers on one page

大憨熊 提交于 2019-12-21 03:20:07
问题 I have a page with multiple controllers, one of the controller is being used in 2 different divs within the same page. I am not sure if it is a scope issue or I just miss something in my code. here is the plunkr http://plnkr.co/edit/IowesXE3ag6xOYfB6KrN?p=preview I want to hide the textbox when the user clicks on 'Savings' link, display the box when clicking on 'Cost' link. 回答1: Every time you use ng-controller, you make a new instance of said controller, with it's own scope. If you set

Rendering Partials From One Controller’s View to Another Controller’s View in Rails

北慕城南 提交于 2019-12-20 08:50:47
问题 I have a view for a controller called "show". Inside that view, i want to render the contents of another controller's view - and obviously, the logic for the form on that view to talk to the controller it belongs too. How do I do this? I am fairly new to rails and I'm not 100% confident with the framework yet. You could almost consider them "widgets" on the view. I know you can render actions from the same controller on the view by using: render :action => "show_home_page", :layout=> false