controller

Call a model method in a Controller

自作多情 提交于 2019-12-20 09:03:42
问题 I'm have some difficulties here, I am unable to successfully call a method which belongs to a ProjectPage model in the ProjectPage controller . I have in my ProjectPage controller: def index @searches = Project.published.financed @project_pages = form_search(params) end And in my ProjectPage model : def form_search(searches) searches = searches.where('amount > ?', params[:price_min]) if check_params(params[:price_min]) @project_pages = ProjectPage.where(:project_id => searches.pluck(:

Usage of MVVM in iOS

两盒软妹~` 提交于 2019-12-20 08:37:56
问题 I'm an iOS developer and I'm guilty of having Massive View Controllers in my projects so I've been searching for a better way to structure my projects and came across the MVVM (Model-View-ViewModel) architecture. I've been reading a lot of MVVM with iOS and I have a couple of questions. I'll explain my issues with an example. I have a view controller called LoginViewController . LoginViewController.swift import UIKit class LoginViewController: UIViewController { @IBOutlet private var

Calling the Session before any Controller Action is run in MVC

天大地大妈咪最大 提交于 2019-12-20 06:29:59
问题 I have this authentication check in my global.asax file in the Session_OnStart() call: if (Session["Authenticated"] == null) { Response.Redirect("~/Login.aspx"); } This kind of session authentication is tightly coupled in all our web apps so I have to use it this way. This global.asax sits in an older Webforms project, which my MVC project is sitting in. So for this reason I believe its letting me access my controller action e.g http://localhost/controller/action directly without my session

Laravel send variable to the view

主宰稳场 提交于 2019-12-20 05:47:12
问题 routes.php Route::post("/{user}/{char_name}", array( 'as' => 'char-profile-post', 'uses' => 'ProfileController@postDropDownList')); Route::get("/{user}/{char_name}", array( 'as' => 'char-profile-get', 'uses' => 'ProfileController@getDropDownList')); ProfileController.php public function postDropDownList($user, $char_name) { $user = Auth::user(); $char_name = Input::get('choose'); $char_name_obj = User::find($user->id)->characters()->where('char_name', '=', $char_name)->first(); return

Binding between variable of html in string and a Model Class with Spring Boot

无人久伴 提交于 2019-12-20 05:40:38
问题 I want to create a binding between variables of html string and a Model Class for a spring boot app and then i will return a html page. Here what I need: @PostMapping(path = {"/hashmap"}) public String GetHtmlPage(@RequestBody Owner owner) { String htmlPage=contractsRepository.getById(1); //i need a solution like "binding" method. //but i don't know which library i can use and //how can i do this implementation String htmlPageAfterBinding=binding(htmlPage,owner); return htmlPageAfterBinding;

Child actions are not allowed to perform redirect actions. (Using PartialViews)

耗尽温柔 提交于 2019-12-20 04:57:11
问题 I'm trying to load my partial view with some data from database, but I'm getting following issue when I run the application: Child actions are not allowed to perform redirect actions. I don't know why this is happening because I'm pretty new with MVC technology. Here is my PartialViewResult method in a controller: public PartialViewResult UnReadEmails() { if (User.Id != null) { List<Emails> resultList = EmailController.GetUnreadEmailsByUserId(User.Id); return PartialView("~/Views/Emails/

HttpMediaTypeNotAcceptableException / HttpMediaTypeNotAcceptableException: Could not find acceptable representation

情到浓时终转凉″ 提交于 2019-12-20 04:56:10
问题 I have a API that a client is trying to connect to. However it throws the error: 2015 09 22 04:21:44.297 [org.springframework.web.servlet.mvc.method.annotation.HttpEntityMethodProcessor] Could not parse Accept header: Invalid token character ',' in token "json,application/x-www-form-urlencoded" 2015 09 22 04:21:44.298 [org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver] Resolving exception from handler [public org.springframework.http.ResponseEntity<java

Grails 3.2.11 not reloading controllers in development

大城市里の小女人 提交于 2019-12-20 03:10:00
问题 In a running app (with gradle bootRun ) I add a simple println params to a controller action: def index( Integer max ) { params.max = Math.min( max ?: 20, 100 ) println params respond Some.list( params ), model:[ someCount:Some.count() ] } In the logs I can see: File C:\workspace-neon\proj\grails-app\controllers\io.smth.SomeController.groovy changed, recompiling... 11:23:08.632 [Thread-14] INFO o.s.b.f.s.DefaultListableBeanFactory - Overriding bean definition for bean 'io.smth.SomeController'

Cant get the Edit function Working

走远了吗. 提交于 2019-12-20 03:01:34
问题 I have two models Employee and Overtime Definition The Associations are set like this Employee class Employee < ActiveRecord::Base has_many :overtime_definitions Overtime Definition class OvertimeDefinition < ActiveRecord::Base belongs_to :employee I created an Overtime definition for an employee and it all looks fine.However I'm having trouble with editing the same for an employee. overtime_definitions__controller: def new @flag = params[:flag] @employee = Employee.find(params[:id])

How to get JSON data in an Odoo controller?

左心房为你撑大大i 提交于 2019-12-20 02:08:33
问题 I am trying to send some JSON data to an Odoo controller, but when I send the request, I always get 404 as response. This is the code of my controller: import openerp.http as http import logging _logger = logging.getLogger(__name__) class Controller(http.Controller): @http.route('/test/result', type='json', auth='public') def index(self, **args): _logger.info('The controller is called.') return '{"response": "OK"}' Now, I type the URL ( http://localhost:8069/test/result ) on the browser to