Menu
  • HOME
  • TAGS

How to set a conditional based on multiple models?

ruby-on-rails,ruby,model-view-controller,notifications,conditional

First of all, according with MVC, you shouldn't make SQL queries in the view's: <% if Comment.find_by(notification.comment_id) == Habit.find(params[:habit_id]) %> bad practice! You should make the Query in the controller and then using the instance variable of the controller(the variable with the @) in the view. Second, params[:habit_id] will only...

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

php,laravel,model-view-controller,laravel-5

The most common reason behind this issue is that you have not changed the permission of storage folder. Please run the following from your laravel root : chmod -R 755 storage if this doesn't works try chmod -R 777 storage ...

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

php,mysql,codeigniter,model-view-controller

You can call your helper in your constructor function __construct() { parent::__construct(); $this->load->helper('url'); } And your ajax url is url: "<?php echo base_url();?>index.php/Welcome/search?>", ...

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

java,image,model-view-controller,javafx

You need to inject the element from the FXML file into the controller so that you can access it there. See the tutorial (the section "Add rows to the table", listings 3-14 and 3-16), or the documentation. Basically, you need to add an fx:id="..." attribute to the definition in 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

The problem is that you are not creating 10 button elements as you expect, you are creating only one. When you create the base prototype object var btn = { btnElem: document.createElement('button') } var parent = Object.create(btn); you create a single DOM element. Then you create an object which uses...

Express get error

node.js,model-view-controller,express

You need to initialize your app like this var app = require('express')(); ...

Raw Database content showing up in Rails View

ruby-on-rails,sqlite,model-view-controller

you don't need the = here: <%[email protected] do |t|%>, the equals sign is telling erb to show every message on the view. <% %> Will execute Ruby code with no effect on the html page being rendered. The output will be thrown away. <%= %> Will execute Ruby code and...

Controller and model/service separation of logic

angularjs,model-view-controller

"Unfortunately, the pragmatic answer is: 'it depends.'" The MVC Model is not necessarily "all that it's cracked-up to be." Nevertheless, I suggest that you can meaningfully divide the problem along this line: "'User Interface' ... versus ... 'Not'" For instance: "the entire exchange with the Gentle User, no matter what...

Laravel 5 passing database query from controller to view

php,laravel,model-view-controller,database-connection,views

controller public function show(Project $project) { $technologies = DB::table('technologies') ->select('*') ->where('id', $project->technology_id) ->get(); // you were missing the get method return view('projects.show', compact('project', 'technologies')); } View This will not work in your view: @if ( !technologies() ) @section('content') <h2>{{ $project->name }}</h2> @if($technologies) <ul> @foreach($technologies as $technology) <li><a href="#">{{ $technology->slug }}</a></li>...

set controller function as link

php,model-view-controller

I'm not sure about your question but this is simple example of using such functionality Test.php <?php echo '<a href="../another_test.php/add_to_cart/?id=1231"/>Click Here</a>'; ?> another_test.php <?php class A{ function __construct(){ } function add_to_cart(){ $id = $_GET['id']; return $id; } } $a = new A(); echo $a->add_to_cart();//1231 ...

Regular Expression for Password strength with one special characters except Underscore

regex,model-view-controller

I think you can use a negated character class [^_]* to add this restriction (also, remove the initial .*, it is redundant, and the first look-ahead is already at the beginning of the pattern, no need to duplicate ^, and it is totally redundant since the total length limit can...

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

Try this: <h4>@Html.Raw(Model.HomePageVM.AboutUsDescOne)</h4> Use this helper with caution though. If a user can edit this block of HTML then you might be making yourself vulnerable to an XSS attack: Text output will generally be HTML encoded. Using Html.Raw allows you to output text containing html elements to the client, and...

MVC with Angular

angularjs,model-view-controller

Think of an Angular app as disconnected from your backend as an Android or iOS app would be. If you're doing it right your entire Angular app is static, with no server side templating (a nice side effect of this is that your Angular app can be pushed to a...

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

spring,rest,spring-mvc,model-view-controller

Add: import org.springframework.http.HttpStatus; ...

Unable to listen to load event in the controller

extjs,model-view-controller

It is done like this: http://docs.sencha.com/extjs/4.2.3/#!/api/Ext.app.Controller-cfg-stores Write your own getter: Ext.define("MyApp.controller.Foo", { extend: "Ext.app.Controller", requires: [ 'MyApp.store.Users', 'MyApp.store.Vehicles' ] getUsersStore: function() { return this.getStore("Users"); }, getVehiclesStore: function() { return this.getStore("Vehicles"); } }); Or shorter Ext.define("MyApp.controller.Foo", { extend: "Ext.app.Controller", stores: ['Users', 'Vehicles'] }); => you can use de storeId, or fullName...

rendering the partials in controller after the validation check

ruby-on-rails,ruby-on-rails-4,model-view-controller

Why this is not working? if params[:user][:user_role] render :partial => 'users/mentor' else render :partial => 'users/mentee' end params[:user][:user_role] is nil. You can check it using lots of way: Above your if condition raise params[:user].inspect Why its nil? Reason of this is You are passing new_user_path(user_role: true) user_role true, but user_role...

How to show commenting user's id in notifications?

ruby-on-rails,ruby,model-view-controller,notifications

How Comment.find_by(notification.user_id) even works? I think correct ways are (first and second are equivalent): Comment.find_by_id(notification.user_id)source Comment.find_by(id: notification.user_id) Comment.find(id: notification.user_id) source If you need just user_id why don't you just write this: notification.user_id instead of Comment.find_by(notification.user_id).user.id...

SimpleMembershipProvider WebSecurity.InitializeDatabaseConnection The login from an untrusted domain

asp.net,database,exception,model-view-controller

I think that you are providing in your connection string UserName and password, so you can change from Integrated Security=True to Integrated Security=False and if the user 'DB_9CB321_Szklarnia_admin' has rights to connect it will work. When Integrated Security=True the userID and password will be ignored and attempt will be made...

How to only let correct_user create or destroy?

ruby-on-rails,ruby,model-view-controller

So I believe you've correctly identified that the problem lies within your correct_user method: def correct_user @habit = current_user.habits.missed_days.find_by(id: params[:id]) redirect_to habits_path, notice: "Not authorized to edit this habit" if @habit.nil? end Take a look at your first line, here's what I read in English: Take the current User Get...

Python MVC style GUI Temperature Converter

python,user-interface,python-3.x,model-view-controller,tkinter

You have two mistakes here: 1 - In your Counter.py file and in your Convert class methods, you are not return the right variables, instead of return celsius you should return self.celsius and same goes for self.fahrenheit 2 - In Controller.py file: self.view.outputLabel["text"] = self.model.convertToFahrenheit(celsius) This will not update the...

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

model-view-controller,sapui5

Meanwhile I have a hacked solution. In the onInit method of the controller I register to the onmousemove event. Each time the mouse will be moved I can check if there is some data to show. this.getView().attachBrowserEvent("mousemove", function(oEvent) { this.onCheckForMessages(); }); But better solutions are welcome....

CI_Model not found in extending class

php,codeigniter,model-view-controller

Try using this in your controller: <?php class Payment extends CI_Controller { function sample() { $this->load->model('PortionCreatorModel', 'pc'); // Reference by using $this->pc echo 'OK'; } } Reference: CodeIgniter: Models...

Swift ios alamofire data returning empty first time in viewDidLoad

ios,swift,api,model-view-controller,alamofire

Your loadAdInfo method is asynchronous. In the same way you're using a completionHandler to get Alamofire's data from adsForSection to loadInfo, you need to make an handler for loadInfo so you can retrieve the asynchronous response. Something like this: func loadAdInfo(section: String, page: Int, handler: (JSON) -> ()) { NWService.adsForSection(section,...

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

angularjs,node.js,model-view-controller,node-webkit,nw.js

I see no reason not to use Angular in an nwjs project. I do it myself in the app I just finished building. It's a local-only deck tracking app for hearthstone that never communicates over the internet at runtime. It only ever monitors a log file that is generated by...

Ninject 1.0 to 2.0 .Only

c#,.net,model-view-controller,ninject

Yes, you are right. Based from the old svn sources it was in 1.0 - http://ninject.googlecode.com/svn/trunk/src/Core/Binding/Syntax/IBindingConditionSyntax.cs , but at the current version it doesn't exist. In the their actual documentation there are a couple of samples on how you can do conditional binding: attributes\named bindings\when methods. I suppose the closest...

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

javascript,jquery,node.js,model-view-controller,sapui5

You mentioned you cannot use the Router mechanism due to company restrictions -- am really curious to know what these restriction are then ;-) -- and toggle the visibility properties of the respective views instead. In that case, I would trigger the OData service in the method where you set...

Parsley Command Decoupled Result Handlers and Observers

actionscript-3,flex,model-view-controller,parsley

With a small tweak to the Controller code, we end up with this: [CommandResult(type="view.user.UserEvent", selector="loadUser")] public function handleResult(result:Object):void { trace("this is the command result"); } OR [CommandResult(selector="loadUser")] public function handleResult(result:Object, trigger:UserEvent):void { trace("this is the command result"); } Now this fires, I get an Object with my data in, resolved....

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

ruby-on-rails,model-view-controller,devise

Something like this should do it, this is in courses controller show action (index action should be the list of all courses, show action should be viewing an individual course): class CoursesController < ApplicationController def index @courses = Course.all end def show @course = Course.find(params[:id]) current_user.viewed_courses.create(course: @course) end end One...

How to set :user_id with comment notifications?

ruby-on-rails,ruby,model-view-controller,notifications,comments

This @valuation = Valuation.find_by(self.valuation_id) @user = User.find_by(@valuation.user_id).id Notification.create( valuation_id: self.valuation_id, user_id: @user, comment_id: self, read: false ) should be self.notifications.create( valuation: self.valuation, user: self.valuation.user ) in your migration file set: t.boolean read, default: false in your controller: def index @notifications = Notification.where(:user_id => current_user.id) @notifications.each do |notification| notification.update_attribute(:read, true) end...

How do I get the id of a list item?

jquery,html,model-view-controller

$('#listItemCss>li').click(function() { var cid = $(this).find('.cssId').val(); console.log(cid); }); Also, don't use the same id for multiple li elements DEMO See Why is it a bad thing to have multiple HTML elements with the same id attribute?...

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

ruby-on-rails,model-view-controller,devise

In the model, you can validate for uniqueness... viewed_course.rb class ViewedCourse ... validates :course, uniqueness: { scope: :user, message: "should happen once per user" } ... end It doesn't look like you're using ViewedCourses in your show template. If you do later, you might want to try the find_or_create_by method...

Disable a Tab in angularjs

angularjs,model-view-controller,tabs

What you can do is give a property disabled, and check that on the tab click: $scope.tabs = [{ title: 'One', url: 'coredcplan.html' }, { title: 'Two', url: 'migration.html', disabled: true }, { title: 'Three', url: 'schedule.html' }]; $scope.onClickTab = function (tab) { if(tab.disabled) return; $scope.currentTab = tab.url; } See...

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

c#,model-view-controller,spark-view-engine

If you override the SparkViewBase, then you need to make sure you have a method there called HTML. The default implementation is: public MvcHtmlString HTML(object value) { return MvcHtmlString.Create(Convert.ToString(value)); } ...

Show the subcategories of the chosen category in Rails 4

javascript,ruby-on-rails,ruby-on-rails-4,model-view-controller,coffeescript

Look in your console or development.log and you're going to see some message indicating that rails could not resolve update_sub_categories when your script fails. Wheras when calling that method with a new form, you'll see that rails is calling your_controller/your_action/update_sub_categories -- you can probably see where this is going now....

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

php,model-view-controller,model,constants,phpfox

Set them as constants in the class. From the PHP manual: <?php class MyClass { const CONSTANT = 'constant value'; function showConstant() { echo self::CONSTANT . "\n"; } } ...

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

ruby-on-rails,ruby,ruby-on-rails-4,model-view-controller

You can use content_for and yields to create a default in your layout which views can override. # layouts/application.html.erb: <% if content_for?(:banner) %> <%= yield(:banner) %> <% else %> <div id="banner"> <h1>This is the default...</h1> </div> <% end %> /users/signup.html.erb: <%- content_for :banner, flush: true do -%> <!-- move along,...

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

c#,asp.net,model-view-controller,asp.net-5

[FromServices] is just an MVC concept. It is not available to other parts of the ASP.NET 5 stack. If you want to pass dependencies down the chain you have a few options: Pass the service provider. This is quite an anti-pattern because your objects need to depend on the DI...

Bad request 400

java,spring,hibernate,jsp,model-view-controller

You are using PathVariable so you need to declare id in value. E.g. @RequestMapping(value = "/editCase/{id}", method = RequestMethod.GET) ...

Sharing controller between views

python,design-patterns,model-view-controller

Passing things as arguments, just like in your code, is the most common solution to problems like this. If you only need the do_this -method, you can even just pass the method: beta = ViewBeta(controller.do_this) ...

Is bootstrap file a controller?

php,oop,model-view-controller,controller

No, bootstrap file is for initialization. A controller is resoponsible for handling user input (requests in a web environment) and providing him an output (responses in a web environment). A front controller is just a centralized point for handling incomming requests. None of these compoments should have the responsibility of...

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

linq,entity-framework,model-view-controller,model

You cannot pass complex objects when redirecting using RedirectToAction. It is used for passing the routeValues not the Model. To maintain state temporarily for a redirect result, you need to store your data in TempData. You can refer this for more info: passing model and parameter with RedirectToAction TempData["_person"] =...

Paperclip dimension validation error in Rails 4

ruby-on-rails,ruby,ruby-on-rails-4,model-view-controller,model

Try this. validates :image, :unless => "image.queued_for_write[:original].blank?", dimensions: { width: 800, height: 550 } ...

Formatting dates in an MVC Dropdown

date,model-view-controller,html-select

Maybe a better way to do this would be to define a property in your model that returns IEnumerable<SelectListItem> (in your model class): public DateTime SelectedDate {get;set;} public IEnumerable<SelectListItem> SeasonDates { get { foreach (var item in seasonDates) yield return new SelectListItem() { Text = item.ToShortDateString(), // or apply your...

How to “link_to” full path in rails 4?

html,ruby-on-rails,ruby,ruby-on-rails-4,model-view-controller

To get the full URL, use gig_url(@gig) instead of gig_path(@gig).

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

ruby-on-rails,ruby,ruby-on-rails-4,model-view-controller,actionmailer

This may work def buyer(gig,user) @gig = gig @email = user.email @name = user.name mail(to: @email, subject: 'box delivery') end def seller(gig, email, name) @gig = gig @email = email @name = name mail(to: @email, subject: 'new box order') end ...

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

ajax,asp.net-mvc-4,razor,model-view-controller,model

To make you understand how AJAX FORM works, I created below code - Lets say our model - public class Sale { public string SaleOwner { get; set; } public virtual Account Account { get; set; } } public class Account { public string Name { get; set; } }...

How to select multiple selected value from select option

angularjs,model-view-controller,ionic-framework,ionic

Here is the jsfiddle I used ng-repeat to build the select and ng-options to fill them, you then have to use the relative ng-model to get the selections. HTML: <div ng-app ng-controller="MyCtrl"> <select class="select fancy" ng-repeat="(i, item) in items" ng-model="searchOption[i]" ng-options="type.name for type in item.types"></select> <button ng-click="submitIt()">Submit</button> </div> Javascript: function...

MVP, JavaFx and components references

java,design-patterns,model-view-controller,javafx

JavaFX has been designed to work with the MVC pattern. Hence it is much easier to use MVC than MVP. In MVP Presenter is responsible for formatting the data to be displayed. In JavaFX, it is done automatically by View. Here's a quick overview of JavaFX MVC: Model - the...

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

mysql,ruby-on-rails,ruby,model-view-controller

You can try this. I hope this will help. @user = User.where("id = ?", 4).select( "user_fname, user_lname") ...

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

1) You have already added where clause. 2) Also your update is before of your where, meaning your query is executing without the where clause and hence it is updating all the records. public function up_votes($id) { $this->db->set('up', 'up+1', FALSE); $this->db->where('open_id', $id); $this->db->update('country'); // ^^ removed `$id` } ...

Correctly format included javascript code when rendering

node.js,model-view-controller,express,view

The EJS readme shows the different tags you can use in your templates. <%= will escape the contents whereas <%- will not, so use the latter.

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

php,laravel,model-view-controller

It is fine to pass a model into a view, a good way to do it is like this: public function show($id) { $thing = Thing::findOrFail($id); return view('showAThing')->with('thing', $thing); } Using findOrFail() in this context will throw a 404 error if the item doesn't exist in your database. This is...

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

Not sure whether it's possible, but it will couple most of your app to the default_scope implementation, which IMHO is a very bad idea. You might end up needing to change this implementation down the line, which is going to have pretty high impact. It will also make your unit...

wxPython MVC working with GUI

python,model-view-controller,wxpython,observer-pattern

The MVC entry in the wxPython wiki gives a good insight how the spearation of concerns could look like. The first (newer) example leverages pypubsub, the older example at the bottom deals with wx.Events alone. While it may or may not conform to the strict MVC paradigma, it shows beautifully...

Trying to Delete Message from List with Rails

ruby-on-rails,model-view-controller,routes

You need to pass the method DELETE as well, otherwise it will perform the simply GET request. Here's how: <%=link_to "Delete Message", delete_path(t), :method => 'delete' %> Remember if you do not mention any method in link_to, the default will be taken as GET. So you have to be explicit...

ServiceStack selfhosting disable caching for memory

model-view-controller,servicestack

Every request does not get cached in memory, when you're self-hosting it's running the binary dlls and static files that are copied into your /bin folder. You can change Config.WebHostPhysicalPath to change ServiceStack to serve files from your solution folder instead, e.g: SetConfig(new HostConfig { #if DEBUG DebugMode = true,...

Why not global $db in model classes?

php,oop,model-view-controller

Why not use inheritance? <?php class model { private $db; public function __construct() { $this->initDb(); } private function initDb(); } 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(); } } class m_blog extends model{ public function __construct()...

Laravel MVC application structure on UML class diagram

php,laravel,model-view-controller,uml,class-diagram

You can simply present a view as a class. Dialog elements can be shown as attributes having types that can be either simple strings (for input fields) or other classes that represent e.g. drop down. Edit Your diagram looks ok. Just add the attributes for the view like +email:Text +password:HiddenText...

zf2 call a method from a Model in another Model

model-view-controller,zend-framework2

This should be fairly simple. Firstly you need to include the two modules in your application.config.php 'modules' => array( 'Module1', 'Module2' ) Then as a very basic example taken from your question: <?php namespace Module2\Model; use Module1\Model\Class1; class Class2 { public function doSomething() { $class1 = new Class1(); $class1->doSomething(); }...

Updating variable through model Backbone

javascript,backbone.js,model-view-controller,updatemodel

It appears your model is accessing the DOM. Usually, your view would deal with the DOM, extracting information then updating the model. So for example, create a view with a constructor that: Creates your input elements and put them in an attribute called $el; then Adds $el to the DOM;...

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

javascript,jquery,forms,backbone.js,model-view-controller

You can use jQuery's serializeArray to collect all data on submit of the form. serializeArray will return you the array of name and value pair of of all the fields in forms, you can simply iterate over those array values and create the required object then set it to your...

AngularJS Spring sort field names

angularjs,spring,model-view-controller,data,hateoas

To be truly HATEOAS compliant, the service (spring) needs to provide to the client all the hypermedia controls (links) to perform sorting. The client should never sort by some data field...it should only sort by what sort options are provided to the client by the server. This sorting may itself...

Undefined variable: content

php,codeigniter,variables,model-view-controller,undefined

You have to pass the $data variable in the view method. Take a look at this: public function edit_news_form() { $this->load->model('users_model'); $id = $this->uri->segment(3); $result=$this->users_model->get_id($id); $data['content']=$result; $this->load->view('edit_news_form', $data); } ...

CMake simple MVC structure

c++,model-view-controller,cmake

It looks pretty normal structure to me. In fact I use the same one in my projects. In the root CMake file you will put: include(Src/Model/CMakelists.txt) and CMakelists.txt might look like this: set(MODEL_HEADERS src/Model/model.hpp) set(MODEL_SOURCES src/Model/model.cpp ${MODEL_HEADERS}) list(APPEND ALL_SOURCES ${MODEL_SOURCES}) source_group("Model" FILES ${MODEL_SOURCES}) Where ALL_SOURCES is the variable from the...

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

You can't use the value of the form as a parameter for the route: @form(routes.Users.updatePassword(userForm.userid.get)) The userid depends on the form and could therefore change. In any case, you would access the userid of the form using userForm("userid") and not userForm.userid (although it might not be what you want/need). A...

Regular Expression date time using MVC Data Annotations

regex,angularjs,validation,model-view-controller

Your regex does not work as expected because you did not use a ^ anchor (although I guess this expression is anchored, but still it is better to play it safe) and you did not enclose the alternatives into a group, and thus 21, 22, 23 are valid values. Here...

Understanding MVC in a QAbstractTableModel

model-view-controller,pyqt,qtableview,qabstracttablemodel

As stated in the comment, your model is your list of object. You should subclass QAbstractTableModel to use this list. Here's my code snippet for this: import sys import signal import PyQt4.QtCore as PCore import PyQt4.QtGui as PGui class OneRow(PCore.QObject): def __init__(self): self.column0="text in column 0" self.column1="text in column 1"...

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

php,mysql,model-view-controller,zend-framework2

Answer The exchange array method shown below needs to have proper case for the $data array elements. I revised all lines starting with the sample one below to have the proper case. Since ActionItemID is a string it needs to have to the proper case of the ActionItemID. Answer Snippet...

MVC communication, update label from model class in Swift

ios,swift,oop,model-view-controller,uilabel

Your error is here var callV = ViewController().label You are creating a new instance of ViewController,you should get the reference of the existing one You can pass in a label as input func changeLabel(label:UILabel){ var elementCall = callElements() println("111") label.text = elementCall } Then call modelFrom.callElements(self.label) Update: I suggest you...

Getting model to save after running method

ruby-on-rails,model-view-controller

The problem is, you did not call any save after calling the method token_exchange, rewrite your method as following, it will save your transaction def token_exchange exchangeTokenResponse = API.exchange_token(public_token) self.access_token = exchangeTokenResponse.access_token self.accounts = API.set_user(access_token, ['auth']) self.transactions = API.set_user(access_token, ['connect']) self.save end ...

Object is not a function (MVC Javascript)

javascript,model-view-controller

You need to call it as a constructor, and define it as a constuct function: var posAttuale = function() { this.myLat = "myLat"; this.myLng = "myLng"; this.myComune = "myComune"; }; var infoPos = new posAttuale(); ...

FluentValidation in Lightinject

c#,model-view-controller,inversion-of-control,fluentvalidation,light-inject

I am the author of LightInject and maybe you could see if this example works out for you. class Program { static void Main(string[] args) { var container = new ServiceContainer(); container.Register<AbstractValidator<Foo>, FooValidator>(); container.Register<IFooService, FooService>(); container.Intercept(sr => sr.ServiceType.Name.EndsWith("Service"), factory => new ServiceInterceptior(factory)); var service = container.GetInstance<IFooService>(); service.Add(new Foo()); } }...

MVC: Using controller that is defined in a referenced project

jquery,model-view-controller

You have to make sure both projects are deployed. In other words, Project B needs to be deployed in much the same way you deploy Project A. Then, you can simply call the controller route for Project B, using the URL to it, just as if you were calling a...

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

vb.net,razor,model-view-controller,model

You need to pass the model instance to the view: Function Details() As ActionResult Dim employee As Employee employee = New Employee employee.EmployeeID = 101 Return View(employee) End Function ...

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

php,laravel,model-view-controller,laravel-5

Give a man a fish and you feed him for a day; Teach a man to fish and you feed him for a lifetime Here's Let me say how to debug(fish) in this situation. 1st Step : Make sure that your call is right You can do it by Route::get('yourcall',...

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

Suppose your template file should also reference the object, since as far as I can see the $humans variable won't automagically jump from the class variable into your method like that. Try this: <?php foreach($this->humans as $human) { ?> <li><?php echo $human ?></li> <?php } ?> ...

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

jquery,ajax,model-view-controller,listbox

Figured out why, apparently I had the same id for every select option...silly me.

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

ios,objective-c,uitableview,model-view-controller,uibutton

The second option will certainly violate MVC pattern. ViewController works like a glue between your models, views and contains all the business logic. ViewController should receive action then make your api call and put formatted data to your views. Usually in my project I always try to move networking code...

Controller class contains too many methods [closed]

c#,asp.net,asp.net-mvc,model-view-controller

15,000 lines, jeez. Aside from what you've obviously stated about moving the code to the business layer (which you should do), I would also consider forming logical groups of those action methods that belong to a certain set of functions. Once you've got these groups, create separate controllers for each...

Get controller for model in Ember

javascript,model-view-controller,ember.js

You can calculate the combined totals in the parent model, like so: total: function() { var amount = 0; this.get('years').forEach(function(item) { amount += item.get('total'); }); return amount; }.property('[email protected]') Where "years" is the child model from the hasMany relationship. This will be dynamically updated any time any of the children change...

Extjs building form on metadata

json,extjs,model-view-controller,dynamic

Surely possible. Basically you use your metadata as items and create the form at any time: var metadata = [ { "allowBlank": false, "fieldLabel": "labelText1", "name": "labelName1", "emptyText": null }, { "allowBlank": false, "fieldLabel": "labelText1", "name": "labelName1", "emptyText": null } ]; Ext.create('Ext.form.Panel', { defaultType: 'textfield', width: 300, bodyPadding: 10, renderTo:...

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

java,model-view-controller,design

Go with your feeling and establish that attribute as a synthetic field in your model. So no extra physical field, but put the derivation function down as a getter. In my opinion that's OK, because that getter does only little more than a really dumb field accessor, and the definition...

How to link_to a show page from another MVC?

ruby-on-rails,ruby,model-view-controller,feed,link-to

To link_to your show page with the code I understand you having you need to resources :activities do resources :valuations end Since it's polymorpic use trackable to find the id and put the line: <%= link_to activity.trackable.name, activity_valuation_path(activity, activity.trackable_id) %> Take this line out from your index: @valuation = Valuation.find(params[:id])...

Unable to load tabbed pages with data

javascript,jquery,angularjs,model-view-controller

I added a comment, but Ill explain here in further details. the plunker you gave shows a simple template change but the controller stay the parent controller or base. you on the other hand want to add unique data and actually render a different page. so if you're using ui-router...

Laravel Sub-menu Within View

laravel,model-view-controller

There are a couple ways you can go about doing this. Templates Create your route. Im assuming a lot about your app here but hopefully you get the picture. If you need help with anything in particular, be sure to update your question with the code youve tried so it...

file_get_contents() expects parameter 1 to be a valid path

image,codeigniter,model-view-controller,controller,file-get-contents

$data contain array values, you have to use upload_data for ex : $data = array('upload_data' => $this->upload->data()); $data = array( 'image' => file_get_contents( $data ) ); change this to $data = array('upload_data' => $this->upload->data()); $data = array( 'image' => file_get_contents( $data['upload_data'] ) ); or you can directly use upload data...

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

html,ruby-on-rails,ruby,ruby-on-rails-4,model-view-controller

<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" data-method="get">Show me everything</a></li> <li role="presentation"><a role="menuitem" tabindex="-1" href="http://www.example.com/gigs?subcategory=Intro" data-method="get">Intro</a></li> <li role="presentation"><a role="menuitem" tabindex="-1"...

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

javascript,arrays,model-view-controller,ember.js

This would work. Long way (just to improve your computed property code): // controller work.js import Ember from "ember"; export default Ember.Controller.extend({ firstElement: function () { return this.get('model').get('firstObject'); // or this.get('model.firstObject'); }.property('model.[]') }); 1) you set works as model in route, so you could get it as model in controller...

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

.net,model-view-controller,parse.com

Yes you can, the ParseQuery class has a method to skip (query.Skip(n)) an amount of objects and also to limit (query.Limit(n)) the amount of objects to be returned by a query. Basically you keep track of the current limit and then just increase the values for skip and limit by...

link_to_remove_association is not removing?

ruby-on-rails,ruby,model-view-controller,cocoon

If the link_to_add_association works, the javascript is loaded correctly. Still a bit confused about what is not working. If clicking the link_to_remove_association does not remove anything visibly from the page, you are missing the correct wrapper-class. By default it should be .nested-fields, but this can be overruled by specifying it...

echo textarea in php

php,codeigniter,model-view-controller

You're missing very basic PHP functionality and knowledge, so I'd advice you to read some coursework on beginner PHP. also, this should fix your problem <textarea name='openletter' id='openletter' style='width: 565px;' rows='8' cols='60'><?php echo $data['openletter'];?></textarea> if you want everything inside an Echo : echo "<textarea name='openletter' id='openletter' style='width: 565px;' rows='8' cols='60'>"....

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

java,swing,design-patterns,model-view-controller,architecture

So, MVC doesn't actually explicitly address persistence. There are really two schools of thought here. Bake it into the model, so that the model becomes "self persisting". Or do it in the controller. Opening it in the view layer is absolutely not accepted practice. There is a definite mixing of...