FAQ Database Discussion Community


in ActiveRecord::Relation, is it preferable to scope by parent in the model or set @parent in the controller

ruby-on-rails-4,activerecord,model-view-controller,scope,parent-child
I have a class which belongs to another. course.rb class Course < ActiveRecord::Base belongs_to :school I currently use a before_action to set the parent instance in the controller. courses_controller.rb class CoursesController < ApplicationController #returns @school. only: [methods] avoids trying to set @school when no school param expected before_action :set_school, only:...

Deleting a view and onclick opening it again, as if it is new - SAPUI5

javascript,jquery,node.js,model-view-controller,sapui5
I have a multiple View setup, a main View and then modules who are opened on button click after certain actions. Right now the view is reset by me whenever its opened, but what I want to accomplish is, when the view is left, that its gone from the core...

Rails 4 how to make enrolment to a course for users (controller, view, model)

ruby-on-rails,model-view-controller,devise
I am currently trying to build a simple learning app with rails and I am facing problems. When a user signs up to a course i try to make a viewed_course record for them so that I can display all the viewed_course on their profile page. I can't figure out...

Object is not a function (MVC Javascript)

javascript,model-view-controller
When I run my app there is an error ` "Uncaught TypeError: object is not a function", source: file:///android_asset/www/js/controller.js (2) I have a class model.js : var posAttuale = { myLat : "myLat", myLng : "myLng", myComune : "myComune" }; and a class controller.js : var infoPos = new posAttuale;...

Formatting dates in an MVC Dropdown

date,model-view-controller,html-select
I have a dropdown list on my page as so: - @Html.DropDownList("dd_dates", new SelectList(@Model.seasonDates), "Please Select") where seasonDates is an IList of dates. The problem is that when the dates are displayed in the dropdown they also have the time on them as well. How do I format the display...

Will handling UIButton touch event inside a UITableViewCell subclass violate MVC?

ios,objective-c,uitableview,model-view-controller,uibutton
There is a UITableViewCell subclass with a UIButton inside. A web call should be made when the button is pressed. The question is whether I should set the action in the controller, or can the action be set within the UITableViewCell subclass? Will the second option violate MVC pattern?...

remote data fetching inside model object in objective c using AFNetworking

ios,objective-c,rest,model-view-controller,afnetworking-2
In all of my iOS application I use this approach to respect MCV, I want to be sure that my implementation is correct and respects the best practices and the MVC design pattern : Singleton of AFNetworking acting as API for network calls: MyAPI.h : #import "AFHTTPSessionManager.h" #import "AFNetworking.h" @interface...

Should I use Angular for a local only NW.js project?

angularjs,node.js,model-view-controller,node-webkit,nw.js
I want to build a mid-size application using NodeJS and NW.js (formerly known as node-webkit). The application will grab some data from the internet but isn't talking with one special service which is under my control. Is it a good idea to use AngularJS nevertheless or is the MVC approach...

MVP, JavaFx and components references

java,design-patterns,model-view-controller,javafx
I've studied all popular GUI patterns - MVP,MVC,MVVM and finally I decided to implement MVP (Supervising Controller). So I have the following OBJECTS(!). Stage<-View<->Model. It's important Stage!=View, it is another object. Between view and model data binding. Besides I have a presenter(controller) which handles all events and works with view...

Extjs building form on metadata

json,extjs,model-view-controller,dynamic
I will build a FormPanel with ExtJs 4 configured by metadata received from server. The meta data (json array) looks like this: { "metaData": { [ { "allowBlank:": false, "fieldLabel:": "labelText1", "name:": "labelName1", "emptyText:": "null" }, { "allowBlank:": false, "fieldLabel:": "labelText1", "name:": "labelName1", "emptyText:": "null" } ] }, "success": true,...

Paperclip dimension validation error in Rails 4

ruby-on-rails,ruby,ruby-on-rails-4,model-view-controller,model
I want in my app user to be able to upload files with at least width:800px and height: 550px I created in app/models/dimensions_validator.rb file and the code class DimensionsValidator < ActiveModel::EachValidator def validate_each(record, attribute, value) dimensions = Paperclip::Geometry.from_file(value.queued_for_write[:original].path) width = options[:width] height = options[:height] record.errors[attribute] << "Width must be at...

Controller class contains too many methods [closed]

c#,asp.net,asp.net-mvc,model-view-controller
I am currently maintaining an application where unfortunately we have ended up in having too many Action methods. On top of this the architecture of this project is not fair from the beginning and every developer continued adding Business logic in the action methods of the Controller class instead of...

How do you send data to controller with ajax.beginform?

ajax,asp.net-mvc-4,razor,model-view-controller,model
This is my method on controller "sale" [HttpPost] [ValidateAntiForgeryToken] public ActionResult Create(Models.account account) { Models.sale creaventa = new Models.sale(); //creaventa.account = cliente; creaventa.createdon = DateTime.Now; creaventa.idaccount = account.id; creaventa.modifiedon = DateTime.Now; creaventa.status = 0; context.sales.Add(creaventa); context.SaveChanges(); // return "venta creada"; return View(); } and this is the partial view @model...

Can the constants be defined inside a model file of a framework in PHP?

php,model-view-controller,model,constants,phpfox
I'm using PHPFox framework. I've to define two constants which would be used only by two functions present within that model class file. So can I define the constants at the beginning of this model class file or would it cause any issue or is it against the coding standards?...

Controller and model/service separation of logic

angularjs,model-view-controller
I understand that business logic belongs in a model and application logic belongs in a controller. Could someone please clarify what business logic does and does not include and what application logic does and doesn't include. Giving consideration to things like redirects, confirmation dialogs etc e.g. /** * Removes a...

How to show a dialog in SAPUI5 triggerd by the controller and not a view event? (Push notification)

model-view-controller,sapui5
In a SAPUI5 controller of a master view I trigger a oModel.read() request to read some data (async). This read will be done each time the page will be reached during navigation. onInit: function() { var that = this; this.getRouter().getRoute("PageName").attachMatched(this.onRouteMatched, this); }, onRouteMatched : function(oEvent) { ... oModel.read(....); // this...

Some doubts related this Swing MVC implementation. Opening a database connection should be a Controller task?

java,swing,design-patterns,model-view-controller,architecture
I am following a Java tutorial related to the implementation of the observer pattern (using Swing) and I have some doubts. My doubts are not related to the observer pattern but about the architecture of this tutorial application (that is based on something like an MVC logic) So it contains...

On rendering from controller, current_page method does not seem to work

ruby-on-rails,ruby,ruby-on-rails-4,model-view-controller
I have a navigation bar included in application.html.erb. Because for some pages, such as the signup page, I need to place additional code inside the navigation bar, I have excluded those pages for showing the navigation bar through application.html.erb and instead included it in their respective view pages. See code...

How to show commenting user's id in notifications?

ruby-on-rails,ruby,model-view-controller,notifications
With a little help from my friends I got the user_id to set correctly for Comment & Notification: [2] pry(main)> Comment.find(8) id: 8, content: "test", goal_id: nil, habit_id: nil, valuation_id: 9, quantified_id: nil, commentable_id: nil, commentable_type: nil, user_id: 1, created_at: Thu, 11 Jun 2015 19:57:26 UTC +00:00, updated_at: Thu, 11...

Correctly format included javascript code when rendering

node.js,model-view-controller,express,view
My project listens to a port. Whenever it receives a request, it reads a couple of XML-files and returns certain chunks of Javascript, concatenated. My problem is that the code is HTML-formatted and put inside the header when rendering the .ejs file. It's built using Express and MVC, by the...

ServiceStack selfhosting disable caching for memory

model-view-controller,servicestack
Using Selfhosting standard ServiceStack MVC Application every request get cached in the memory. Changing any js file have no conscience until i restart the server. Is there any way around this problem for developing purposes?

Which could be the cause of a variable not being printing in an HTML template called from another PHP class?

php,templates,model-view-controller
I'm developing the base of an MVC project in PHP. I'm advancing with the View part, but something is now working as expected in the rendering of the HTML template. Here are some contents of the files I'm coding to make this work: my_project_root/views/templates/humans_list.php <!doctype html> <html> <head> <meta charset="utf-8">...

NullReference Error while assiging values of Modeltype in MVC View (Razor)

vb.net,razor,model-view-controller,model
I have the following MVC Model: Public Class Employee Public Property EmployeeID As Integer End Class Controller: Namespace Controllers Public Class EmployeeController Inherits Controller Function Details() As ActionResult Dim employee As Employee employee = New Employee employee.EmployeeID = 101 Return View() End Function End Class End Namespace View: @ModelType MVCDemo.Employee...

Determine if field (on submit event) is a dropdown or a input

javascript,jquery,forms,backbone.js,model-view-controller
My issue is that on my button that is named submit; I want to save data to my model from the view once the submit button is clicked. I want to store each field input into an object so I can store the data in my model. The issue is...

Laravel Sub-menu Within View

laravel,model-view-controller
Hi I am very new to Laravel and MVC frameworks in general and am looking to create a list of links (in a view within a template) that links to some content. I am using this to display a list of nine people and to display their profile description when...

CI_Model not found in extending class

php,codeigniter,model-view-controller
I can't instantiate my models manually on my controller using require_once, following is the problem: Controller <?php require_once './application/models/portion/portioncreatormodel.php'; class Payment extends CI_Controller { function sample() { $pc = new PortionCreatorModel(); echo 'OK'; } } Model <?php class PortionCreatorModel extends CI_Model { function __construct() { parent::construct(); } } When I...

How to only let correct_user create or destroy?

ruby-on-rails,ruby,model-view-controller
How can we get it where only the correct_user can create or destroy here? class DaysMissedController < ApplicationController before_action :logged_in_user, only: [:create, :destroy] before_action :correct_user, only: [:create, :destroy] def create habit = Habit.find(params[:habit_id]) habit.missed_days = habit.missed_days + 1 habit.save! level = habit.levels.find(params[:level_id]) level.missed_days = level.missed_days + 1 if level.missed_days ==...

link_to_remove_association is not removing?

ruby-on-rails,ruby,model-view-controller,cocoon
How can we fix the nested_attribute: _result_fields.html.erb so that when a user clicks "Delete" that it actually deletes it? Whereas now clicking it does nothing. <%= f.text_field :result_value, class: 'form-control', placeholder: 'Enter Result' %> <%= f.date_select :date_value, :order => [:month, :day, :year], :with_css_classes => true, :class => "date-select" %> <%=...

why my views didn't show in laravel 5 [closed]

php,laravel,model-view-controller,laravel-5
I install laravel-5 on ubuntu 15.04 but it did not shows my views or standard views should I do anythings more? its my route.php file: <?php Route::get('/', [email protected]'); Route::get('home', [email protected]'); Route::controllers([ 'auth' => 'Auth\AuthController', 'password' => 'Auth\PasswordController', ]); ...

set controller function as link

php,model-view-controller
I have created simple mvc in php. My controller is : class front { function __construct() { } function add_to_cart() { echo "123";exit; } } Now, I want to pass id into this controller. My view page is: <a href="http://localhost/bhajipala_latest/controllers/front.php/add_to_cart/<?php echo $pr_value['itemID']; ?>" class="site-button-dark"><span>ADD TO CART</span></a> So, what link I...

Why not global $db in model classes?

php,oop,model-view-controller
Let's say that we have a MVC pattern. If we have something like this: blog_controller.php <?php class c_blog{ private $model; public function __construct(){ include( [model_path] ); $this->model = new m_blog(); } public function post_list(){ return $this->model->get_list(); } } blog_model.php <?php class m_blog{ public function get_list(){ global $db; $sel = $db->query("...");...

Where and clause in codeigniter for voting system

php,mysql,codeigniter,model-view-controller
I am implementing a voting system in codeigniter: The problem is that everytime a user clicks on upvote $this->db->set('up', 'up+1', FALSE); is executed and up is incremented by one. But it should only increment if count == 0. My Model code is : public function up_votes($id,$ip) { $query = $this->db->query("SELECT...

MVC with Angular

angularjs,model-view-controller
I am a bit confused. As a contractor I look out for what technologies I should learn to make me more marketable. I am a MVC Web Developer. I have noticed Angular.js seems to be listed as a wanted skill in job adverts alongside MVC skills. Looking at Angular it...

Updating variable through model Backbone

javascript,backbone.js,model-view-controller,updatemodel
I have a base model, that is creating a view with several div's. It is not actually a form; but it is acting as a form. I have variables being set with defaults as well. Here's my model right now: var BaseModel = require('base-m'); var SomeModel = BaseModel.extend({ defaults: function()...

MVC communication, update label from model class in Swift

ios,swift,oop,model-view-controller,uilabel
I have a Model class, which has two methods: func callElements() -> String { if(count < elementsToShow.count - 1) { count += 1 var element = elementsToShow[count] println(element) return element } else { return "No more buttons" } } func changeLabel(){ var callV = ViewController().label var elementCall = callElements() println("111")...

file_get_contents() expects parameter 1 to be a valid path

image,codeigniter,model-view-controller,controller,file-get-contents
My image is uploading to images/news successfully. I want to now save that image in the database. but it keeps giving me the above error. My model query is correct because i use it to insert other data and it works. How can i save the image into the database...

Ninject 1.0 to 2.0 .Only

c#,.net,model-view-controller,ninject
Hi I am following below link, http://codeclimber.net.nz/archive/2009/02/10/how-to-use-ninject-to-inject-dependencies-into-asp.net-mvc.aspx I get error on line: kernel.Bind<IHttpController>().To<MyTESTController>() .Only(When.Context.Variable("controllerName") .EqualTo("CorporateRequirementsController")) .InjectPropertiesWhere(p => p.Name == "ActionInvoker"); I believe .Only is the syntax from Ninject 1.0, what is the equivalent in 2.0? The error I am getting is like this:...

Get controller for model in Ember

javascript,model-view-controller,ember.js
If I have a reference to a model in Ember, how do I access its controller? If you're in the controller and want to access the model it's as simple as .get("model") but the reverse does not seem to hold when you need the controller.

Raw Database content showing up in Rails View

ruby-on-rails,sqlite,model-view-controller
You can see here that it seems like the raw contents of my DB are being printed to the page. I can't see anywhere in my code why there would be the raw output of the db printed to the view. Here is the code for the index view: <div...

Disable a Tab in angularjs

angularjs,model-view-controller,tabs
I have created a demo at plnkr. I want to disable a particular tab say migration, I tried by writing disabled: true but it doesn't seem to work. http://plnkr.co/edit/0XgquovKIICmgGcSVSef?p=preview html code: <!doctype html> <div ng-app="TabsApp"> <head> <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.0.8/angular.js"></script> <script src="http://angular-ui.github.io/bootstrap/ui-bootstrap-tpls-0.6.0.js"></script> <script src="example.js"></script> <link...

How to select multiple selected value from select option

angularjs,model-view-controller,ionic-framework,ionic
My controller code looks like $scope.items = [{ heading: 'Sports', types: [{ name: 'Football', }, { name: 'Persie', }, { name: 'Ronaldo', }, { name: 'Messy', }], id: '1' }, { heading: 'Cricket', types: [{ name: 'Tendulkar', }, { name: 'Lara', }, { name: 'Ponting', }], id: '2' }]; My...

Select2 using Ajax (multi select) - when selecting second one first one disappars

jquery,ajax,model-view-controller,listbox
I am stuck on this problem - the ajax call retrieves the categories ok from the database, and when I select the search result the first time it also shows up in the search box. It is only when I select the search result the second time, first and second...

echo textarea in php

php,codeigniter,model-view-controller
Please let me know How to echo textarea, Tried several versions but dint work. The whole page is in php. I am using codeigniter framework echo "<textarea name='openletter' id='openletter' style='width: 565px;' rows='8' cols='60'>"; <?php echo "$data['openletter']"; ?> </textarea>"; ...

Rails how to make this view work? Devise, Enrolment system with courses

ruby-on-rails,model-view-controller,devise
How can I modify the view to make it work? I would like to have a "enroll now button" that will create a viewed_lessons record for the current_user? class Course has_many :lessons end class Lesson #fields: course_id belongs_to :course end class User has_many :viewed_lessons has_many :viewed_courses end class ViewedLesson #fields:...

Laravel 5 passing database query from controller to view

php,laravel,model-view-controller,database-connection,views
I'm new to Laravel 5 and MVC frameworks in general. I having trouble getting results from a database query and passing it to my blade view. Here is what I have for a controller function ... public function show(Project $project) { $technologies = DB::select('select * from technologies where id =...

return first element from array as computed property from Ember controller subclass

javascript,arrays,model-view-controller,ember.js
I am trying to return the first element of my array as a computed property to my template from my controller. My code is below. I am 100% about my array and template. Problem is my syntax about in the controller. Basically my array is works made of Work objects....

How to set a conditional based on multiple models?

ruby-on-rails,ruby,model-view-controller,notifications,conditional
notifications/index has <%= render partial: "notifications/notification", collection: @notifications %>, which contains: <% if Comment.find_by(notification.comment_id) == @habit %> <%= link_to "your habit", habit_path(notification) %> <% else %> <%= link_to "your value", valuation_path(notification) %> <% end %> which shows gives the error for the 1st line: Couldn't find Habit with 'id'= even...

AngularJS Spring sort field names

angularjs,spring,model-view-controller,data,hateoas
I'm developing an application using AngularJS for the front-end part and Spring for the back-end. I have mainly two entity classes : @Entity public class Project implements Serializable { private static final long serialVersionUID = 1L; /** * idProject */ @Id @GeneratedValue(strategy=AUTO, generator="PROJECT_SEQ") private Integer idProject; /** * name */...

Are calculated quantities a part of the Model, View or Controller?

java,model-view-controller,design
Say I have a Model-View-Controller type application. The model is a car with an engine and tires etc. The speed of the car is a derived/calculated non-persistent quantity that depends on the engine and tires. Should the speed be a part of the model? Or should it be a part...

Express get error

node.js,model-view-controller,express
I am setting up routes to my application controller on a node server - var http = require('http'); var app = require('express')(); app.get('/<path>/<query type>', function(req, res) { //Expecting query parameter <query type>?name=<something> var query = req.query.name; var path = '/<path>/<query type>?name='+query; var options = { host: 'localhost', port: 8080, path:...

Getting contents with extract($variables), but the variables are undefined

php,arrays,variables,model-view-controller,extract
I haven't gotten the hang of the extract() function, and transferring variables. I have a method in a user controller where some variables are defined, and sent in an array to a view function in a parent controller, where the array is extracted. Then the view is required. But the...

How to show the buyer name in Rails 4-Action Mailer Views

ruby-on-rails,ruby,ruby-on-rails-4,model-view-controller,actionmailer
In my app after the buyer bought a gig, both the buyer and the seller get an e-mail to their inbox informing them about it. This is the model for user_mailer.rb: class UserMailer < ActionMailer::Base default from: "[email protected]" def buyer(gig,email) @gig = gig @email = email mail(to: @email, subject: 'box...

MVC: Using controller that is defined in a referenced project

jquery,model-view-controller
I have an MVC project A that references another project B. Is it possible to make an ajax call to an action method in a controller that is defined in project B? $.ajax({ url: "/ThatController/CountyJSON/?Country=" + $('#JobCountry').val()... What should I put in place of "ThatController"? Thanks....

Visual Studio.net MVC: The model on a view is null

linq,entity-framework,model-view-controller,model
I am using RedirectToAction to load a new page after login and pass in the database model with it. RedirectToAction("AdministrationPortal", "Manage", person); person.user model is a User class created by the entity framework. The model of person is class Person { public User user { get; set; }; public string...

Understanding MVC in a QAbstractTableModel

model-view-controller,pyqt,qtableview,qabstracttablemodel
I have some data which are represented by a class of my own ; to fix the ideas I give an example. class MyOwnModel(): def __init__(self, name="", number=0): self.name = name self.number = number I then have a list of such instances, that I want to represent in a QTableView....

Getting model to save after running method

ruby-on-rails,model-view-controller
I have a model that creates and then runs several API calls to fill in the fields. I can get the API calls to run properly in my console but when I try and run it in the app it does not save and I am unsure it runs the...

Sharing controller between views

python,design-patterns,model-view-controller
I have a frame which holds 2 views. I want to use a common controller for both of them but not instantiate 2 controllers. How do i achieve this? Singleton? Send the controller as an argument? Note, the controller will hold temporary data (bad idea?) that will be sent away...

How to link_to a show page from another MVC?

ruby-on-rails,ruby,model-view-controller,feed,link-to
I get this error when I pull up http://0.0.0.0:3000/activities: ActiveRecord::RecordNotFound in ActivitiesController#index Couldn't find Valuation with 'id'= Line: @valuation = Valuation.find(params[:id]) activities_controller def index @activities = Activity.order("created_at desc").paginate(:page => params[:page]) @valuation = Valuation.find(params[:id]) end activities/index <% @activities.each do |activity| %> <%= render "activities/#{activity.trackable_type.underscore}/#{activity.action}", activity: activity %> <% end...

Reading from database in Laravel 4

laravel,model-view-controller,controller,blade
How can I get the image url stored in my database and render it on the page in laravel 4?

Error Number: 1064 You have an error in your SQL syntax; right syntax to use near '3 = ''' at line 1

php,mysql,database,codeigniter,model-view-controller
I want to set up (int) in my table country to up=up+1. I am trying to match open_id (PK) to $id. A Database Error Occurred Error Number: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax...

Python MVC style GUI Temperature Converter

python,user-interface,python-3.x,model-view-controller,tkinter
#The view (GuiTest.py) import tkinter import Controller class MyFrame(tkinter.Frame): def __init__(self, controller): tkinter.Frame.__init__(self) self.pack() self.controller = controller #Output Label self.outputLabel = tkinter.Label(self) self.outputLabel["text"] = ("") self.outputLabel.pack({"side":"right"}) #Entry Space self.entrySpace = tkinter.Entry(self) self.entrySpace["text"] = ("") self.entrySpace.pack({"side":"left"}) #two convert buttons self.convertButton=tkinter.Button(self) self.convertButton["text"]= "Fahrenheit to...

Regular Expression date time using MVC Data Annotations

regex,angularjs,validation,model-view-controller
I'm mixing MVC Data Annotations and AngularJs validations ng-pattern. What I've done so far is this thing: [RegularExpression("/^[0-9]{4}-[0-9]{2}-[0-9]{2} 20|21|22|23|([0-1][0-9]):[0-5][0-9]:[0-5][0-9]$/", ErrorMessage = "Date format: yyyy-mm-dd hh:mm:ss")] As you can see, I try to format date: yyyy-mm-dd hh:mm:ss. I want to make it 24 hours time. My problem is that form is...

PHP/Zend Framework 2 - Unable to display table field values within dynamically generated table

php,mysql,model-view-controller,zend-framework2
Problem I am trying to display field values into a table using Zend Framework 2 and PHP/MySQL. Given the following table which is dynamically generated, I am trying to get the values shown below. Unfortunately, I only get empty values for the cell locations. Question How can I solve this...

wxPython MVC working with GUI

python,model-view-controller,wxpython,observer-pattern
I have a working program in 1 class. I wish to convert it to MVC pattern. I've implemented observer design as shown here and i opened 3 .py files for Model, View and Controller. I'm having trouble understanding what goes where. For example: this code in the original class helpMenu...

calling controller function from view and retrieving rows from db using AJAX in codeigniter

php,mysql,codeigniter,model-view-controller
I am trying to retrieve rows from database by making an AJAX call to the controller function. I have no error messages and the code is executing properly upto $("#msgbox").html("Type the name of someone or something..."); I think the controller is not called properly from the view. Below is my...

Unable to load tabbed pages with data

javascript,jquery,angularjs,model-view-controller
I have a task where I have to tab 3 different html pages under 3 tabs. All these pages load the grids with data as soon as user navigates to them. I am able to tab my html pages.There is a working plunkr of that. http://plnkr.co/edit/0XgquovKIICmgGcSVSef?p=preview But the problem is...

Swift ios alamofire data returning empty first time in viewDidLoad

ios,swift,api,model-view-controller,alamofire
I am trying to load data from an API into my viewcontroller but the first time it loads the data returns empty import UIKit class AdViewController: UIViewController { var adId: Int! var adInfo: JSON! = [] override func viewDidLoad() { super.viewDidLoad() loadAdInfo(String(adId),page: 1) println(adInfo) // This shows up as empty...

How to set :user_id with comment notifications?

ruby-on-rails,ruby,model-view-controller,notifications,comments
Whenever a notification is created how can we set the :user_id for the user who made the comment (and in affect the notification)? When I check rails console for some reason all Notifications are showing up as user_id: 1 when some of them should be user_id: 2 since the latter...

rendering the partials in controller after the validation check

ruby-on-rails,ruby-on-rails-4,model-view-controller
I have two partial views for two different sign up forms. On my home page , based on the link one clicks on, I'm rendering respective form.(views/application/index) = link_to 'Mentor', new_user_path(user_role: true), :class =>'btn' = link_to 'Mentee', new_user_path, :class =>'btn' In views/users/new.html.haml , I'm checking the user role and redirecting...

Model.Finder Deperecated Play! 2.4

java,model-view-controller,playframework,ebean
I am building an application using the latest version of Play!. When defining a Finder( as in Model.Finder) my IDE gives me a warning Finder is deprecated. I can't find any information in the documentation about Model.Finder being deprecated of any alternative to using it. Has anyone experienced a similar...

Show the subcategories of the chosen category in Rails 4

javascript,ruby-on-rails,ruby-on-rails-4,model-view-controller,coffeescript
1. In my **view/gigs/new.html.erb i use <%= f.collection_select :category_id, Category.all, :id, :name, {prompt: "Choose a category"} %> <%= f.collection_select :subcategory_id, Subcategory.all, :id, :name, {prompt: "Choose a subcategory"} %> It creates this and when clicked the below image: From the picture above as you see depending on what category i choose,just...

Dependency Injection asp.net 5 custom classes, what is correct way?

c#,asp.net,model-view-controller,asp.net-5
Trying to understand DI. What is correct way to use services/dependency objects in custom classes? Do i need to create each class as service and add to dependency objects? Or should I be using [FromServices] (previously, [Active] before beta4 ) attribute. or is there is a service object I should...

JavaFX - How do you open and display an image in a pane?

java,image,model-view-controller,javafx
I am trying to create an application that will allow users to open an image file and display it in a pane. I have chosen JavaFX to create the GUI but this has presented some difficultly with the code below: public class Controller implements Initializable { ... public void openFile()...

Is bootstrap file a controller?

php,oop,model-view-controller,controller
Sometimes, there are things that should be done at the very beginning of execution. And, I called it 'bootstrap' or 'initialization'. In bootstrap file, I usually disable the magic quotes at the runtime, set up the database adapter,defining paths, registering the autoloader, etc. Is it right to put that bootstrap...

Laravel: Is it bad practice to pass models to views?

php,laravel,model-view-controller
In the examples I have seen so far, concrete values are always passed to views - be it as separate variables, or as arrays. Example from the Laravel documentation: $view = View::make('greeting')->with('name', 'Steve'); Is it a bad idea to pass a model to a view? In my controller I use:...

“Error: HttpStatus cannot be resolved to a variable” How to resolve This?

spring,rest,spring-mvc,model-view-controller
I am getting error in below code at line 2: @ResponseStatus(HttpStatus.OK). Error is: "HttpStatus cannot be resolved to a variable". What imports are required for this? Am i missing any necessary jar file? Any help? @RequestMapping( value = "/{id}", method = RequestMethod.GET ) @ResponseStatus(HttpStatus.OK) @ResponseBody public String validateUser( @PathVariable( "id"...

CodeIgniter - How to get a list of all my controllers dynamically?

php,codeigniter,model-view-controller
I need to run a function to do some actions with each controller-name on my project. My function is defined on a controller like this: class Some_Controller extends CI_Controller{ public function someActions(){ // $listOfAllControllers = some_method_I_need_for_my_answer(); foreach($listOfAllControllers as $controllerName){ // some_action($controllerName) } } } What I want is a dynamic...

Spark Macro error (The name Html doesn't exists in current context)

c#,model-view-controller,spark-view-engine
We are working in a project where Spark view engine has been used. We are updating the framework and version of the project. After updating the version we are getting error "The name Html doesn't exists in current context" only in those .spark files where macro is used. If we...

Laravel MVC application structure on UML class diagram

php,laravel,model-view-controller,uml,class-diagram
As shown in many examples, MVC architecture involves three classes - Model, View and Controller respectively. With this, it is simple to show MVC on UML class diagram. However, in Laravel the view is not a class directly, it is a page. Can you please tell me, how to display...

Possible way to get objects from Parse.com in intervals of 5 on .NET MVC?

.net,model-view-controller,parse.com
My current system loads all items at once, and displays them 5 at a time using a variation of MVC Infinite Scroll. However, as the database gets larger the initial loading times are sluggish. Does Parse.com allow querying items by using an index? What could be a potential fix or...

Regular Expression for Password strength with one special characters except Underscore

regex,model-view-controller
I have the following regular expression: ^.*(?=^.{8,}$)(?=.*\d)(?=.*[!@#$%^&*-])(?=.*[A-Z])(?=.*[a-z]).*$ I am using it to validate for At least one letter least one capital letter least one number least one special characters least 8 characters But along with this I need to restrict the underscore (_). If I enter password Pa$sw0rd, this is...

Unable to listen to load event in the controller

extjs,model-view-controller
I scanned many threads here at stackoverflow (this and this), but none of them helps me to solve my problem. So, I have a store which is defined like this: Ext.define('fileseditor.store.fileseditorNavigStore',{ extend:'Ext.data.TreeStore', ... I've heard about getters and tried to do this in my controller: init: function(){ this.getfileseditorNavigStoreStore().addListener('load', this.finishedLoading, this);...

Play Scala activator compile command shows value userid is not a member of play.api.data.Form[models.Changepas sword]

scala,model-view-controller,playframework,playframework-2.0,typesafe-activator
I am new to play framework(Scala),In my project I need to update new Password for this I need to get user id which is Primary key for that user table. Based on this unique user id value i will update Password. What I need need to get user table's user...

Parsley Command Decoupled Result Handlers and Observers

actionscript-3,flex,model-view-controller,parsley
I posted a question last night that after reading back sounded awful, so I deleted it and have come back to try again, this time properly. I have a Flex Mobile App, that uses Parsley, everything works as expected but I am trying to do use a decoupled result handler...

How to make a multi model tag_cloud with a join table?

ruby-on-rails,ruby,model-view-controller,tags,acts-as-taggable-on
I have a join table create_table "combine_tags", force: true do |t| t.integer "user_id" t.integer "habit_id" t.integer "valuation_id" t.integer "goal_id" t.integer "quantified_id" end whose purpose is to make a tag_cloud work for multiple models. I put this in the application_controller def tag_cloud @tags = CombineTag.tag_counts_on(:tags) end My tag_cloud looks like this:...

How to find a record by id and select few columns, ruby on rails?

mysql,ruby-on-rails,ruby,model-view-controller
I have a User model that has all the queried fields with the existing data in the database. When I execute the following query- @user = User.find(4, :select => 'user_fname, user_lname') Rails throws the following error for the above line Couldn't find all Users with 'user_id': (4, {:select=>"user_fname, user_lname"}) (found...

Bad request 400

java,spring,hibernate,jsp,model-view-controller
I have Spring/Hibernate/MVC/Maven application. I want to send an ID of my object through request URI. This is my controller: @RequestMapping(value = "/editCase", method = RequestMethod.GET) public String getEditCase(@PathVariable("id") Long id, ModelMap model) { System.out.println("reached!"); .... return "editCase"; } But when I try to retrieve this page, I get 400...

Convert html “href=” into “link_to” for Rails 4

html,ruby-on-rails,ruby,ruby-on-rails-4,model-view-controller
This is the code i want to convert into link_to <ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu1"> <li role="presentation"><a role="menuitem" tabindex="-1" href="http://www.example.com/gigs?category=Video+and+animation">Show me everything</a></li> <li role="presentation"><a role="menuitem" tabindex="-1" href="http://www.example.com/gigs?subcategory=Intro">Intro</a></li> <li role="presentation"><a role="menuitem" tabindex="-1"...

FluentValidation in Lightinject

c#,model-view-controller,inversion-of-control,fluentvalidation,light-inject
I'm using fluentvalidation and lightinject Here is my code to insert a blog article; public OperationResultDto Add(BlogArticleDto blogArticleDto) { OperationResultDto result = new OperationResultDto(); ValidationResult validationResult = _blogArticleModelValidator.Validate(blogArticleDto); if (!validationResult.IsValid) { result.IsOk = false; ValidationFailure firstValidationFailer = validationResult.Errors.FirstOrDefault(); if (firstValidationFailer != null) { result.Message = firstValidationFailer.ErrorMessage; } return result; }...

CMake simple MVC structure

c++,model-view-controller,cmake
I have a simple question about how to organize my simple MVC application in C++. I'm new to CMake and I'm just learning how to use it. Imagine a simple folder organization like the following: -Can someone please tell me if this structure is correct? -If so what is the...

MVC of a button to implement different types of button.Looping of the button element doesnot display all the elements in div

javascript,html,model-view-controller,event-handling,javascriptmvc
I want to implement MVC of a button. I have created a button using var btn = {btnElem : document.createElement('button')} ; now i want to inherit this button into different types of buttons like arthimetic or logical button. so I used this btn object to get the arthimetic button var...

Undefined variable: content

php,codeigniter,variables,model-view-controller,undefined
My error:Message: Undefined variable: content the "content"variable used in my view is apparently not defined. however, when i do var_dump($result); to test the content.. i get: array(1) { [0]=> array(7) { ["id"]=> string(3) "148" ["description"]=> string(9) "33" ["date"]=> string(10) "2015-05-30" ["status"]=> string(1) "1" ["Title"]=> string(2) "33" ["notes"]=> string(9) "33" ["time"]=>...

SimpleMembershipProvider WebSecurity.InitializeDatabaseConnection The login from an untrusted domain

asp.net,database,exception,model-view-controller
I export the database to the server and i've problem. When I start application i see this error An exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dll but was not handled in user code Login failed. The login is from an untrusted domain and cannot be used with Windows authentication. WebSecurity.InitializeDatabaseConnection("DefaultConnection",...

How to “link_to” full path in rails 4?

html,ruby-on-rails,ruby,ruby-on-rails-4,model-view-controller
This is the code i have <a <%= link_to "open your box", gig_path(@gig), class: "mcnButton", target: "_blank", style: "font-weight: bold;letter-spacing: 0px;line-height: 100%;text-align: center;text-decoration: none;color: #FFFFFF;"%></a> from the above <%= link_to "open your box", gig_path(@gig) Note gig_path(@gig) it gives me the url http://gigs/3,and it works well,it found the gig i need...

MVC - How to render a 'a href' link in a View that's been stored in a database?

asp.net-mvc,asp.net-mvc-4,model-view-controller
Question background: I have an MVC4 app whos homepage data is supplied from a View Model. The Issue: Within the View Model I have a property called AboutUsDescOne This is set from the Controller and Action Method from data that has been retrieved from a database. Within the data set...

zf2 call a method from a Model in another Model

model-view-controller,zend-framework2
I have a couple of modules in ZF2 project. Each module has different model classes performing different required functions. Now I have method in a model class of first module which I want to call in the model class of second module. Is it possible to do so? if yes,...

Undefined Variable error while passing data from controller to blade in laravel 5

php,laravel,model-view-controller,laravel-5
Allright, Here is my index() method of UserController public function index() { $name = 'Ashutosh'; return view('home', compact('name')); } As simple as that, and here my home.blade.php code <span class="info-box-number">{{$name}} </span> This must work ideally as per documentation, but it returns undefined variable error Undefined variable: name (View: C:\xampp\htdocs\laravel1\resources\views\home.blade.php) Any...

Include after ob_start(), nothing happen

php,model-view-controller,view,render
I'm trying to render my views with a function. But if start ob_clean(), all code after doesn't affect something. If i include before ob_clean() I see the template. public function render($template, $data = array()) { if (!empty($data)) { extract($data); } $templatePath = TEMPLATE_DIR . $template . '.tpl'; ob_start(); if (!is_file($templatePath))...

How do I get the id of a list item?

jquery,html,model-view-controller
I have a checkboxlist where each item has an id. When the text of an item is clicked the id("cssId") should be printed out in console.log. Checkboxlist: <div id="cssListBox" class="list-group"> <ul id="listItemCss"> @foreach (var item in Model.CssTemplates) { <li id="itemInList"> @Html.CheckBox("ChoiceBox", item.IsConnected) @Html.Hidden("cssId", item.Id, new { @class = "cssId" })...

Trying to Delete Message from List with Rails

ruby-on-rails,model-view-controller,routes
So I have a simple list of messages that users can submit. I'm trying to put a delete button (that works) for each message. But as you can see here you get an error about an entirely different action if you click the button. I'm not totally sure about where...