Tag Info

New answers tagged

-1

For an alternative very well written viewpoint: https://r.je/views-are-not-templates.html


1

Typically, I think the duplication is best handled by pushing the shared code up into a superclass (either in ApplicationController or some other superclass your controller inherits from) as a private method. I think nowadays DHH wants you to put your shared code in modules (erm, i mean concerns), and include those in your controllers, as opposed to shoving ...


2

You may be having trouble if you are thinking of all MVC as a 1 to 1 relationship of View to Controller and a View per Page. A view is not necessarily a page and a page is not necessarily a single view. Commonly they are 1 to 1, but often there is more to it. You might have pages made up of a handful of views, though there will usually be one master view ...


0

The ViewModel object is not what gets stored in a database table, generally. It's the individual items in the ViewModel object that get stored. Each of those items already has an ID. For example: public class InvoiceViewModel { public Customer Customer { get; set; } public Address BillingAddress { get; set; } public Address ShippingAddress { ...


1

The conversion to int should take place in the Controller. The fact that the user enters the number of pages into a control that was designed for general text input is a pure User Interface concern and that should not bleed through to the Model. Similarly, if the value is received over a text-based communication channel (such as HTTP), the conversion ...


2

Short version: Why are you serving up Angular views dynamically? The root of the problem Looking at your example, it seems like you're using Razor views to inject the model's data into the view. This seems to be a fairly counterproductive way of getting data into Angular. The full route is something like: MVC controller -> Razor View -> Angular ...


0

Disclaimer: There are so many other factors in play that your decision on which approach to use should probably not be made solely on this evaluation. Consider team skill sets, long-term maintainability, features needed versus features provided by various frameworks, which client platforms/devices you need to support, and so on. However, from a purely ...


1

If you want to use AngularJS on the client side and Laravel on the backend is to first build a start page where your application loads and lives. And around that to build JSON-services (in laravel or some other, controller methods that handles responses and requests, your CRUD). If you have a lot of different objects (tables?), make a start view for each ...


1

One popular php framework allows faking PUT/DELETE requests by adding a _method=PUT argument to your form action: <form method="POST" action="/customers/12345?_method=PUT"> Internally, the framework converts the POST request to a PUT request. http://symfony.com/doc/current/cookbook/routing/method_parameters.html#faking-the-method-with-method ...


1

How do I know what to do, if I can't use PUT in a form tag? There seems to be some confusion between your application (the server) and one possible client of your application (the web browser talking to the server). You most certainly can use PUT on the server. As vrostu says web browsers use HTML and HTML has not kept up well with HTTP. HTTP has had ...


1

HTML forms can only be submitted by GET and POST. Many applications that use REST services don't rely on HTML forms because of these limitations, and instead submit data by AJAX where you are not limited to just two verbs. There are endless existing libraries for doing this in Javascript (jQuery, Angular $http, etc). Additionally you are not limited to ...


2

In a complex routing system, generally a controller should be looked up by a name that is based on what its job is or what route it handles. When your app "boots up" you register controllers under those names so that the class name isn't hard coded everywhere, allowing you to swap out controllers easily. This is what the App facade in Laravel does. There is ...


0

You could use the simple meta refresh method - http://en.wikipedia.org/wiki/Meta_refresh Or you can use as you have stated a 302 Redirect - http://en.wikipedia.org/wiki/HTTP_302 With the 302, you can perform this in your server side code, or if the AppHarbour web server allows, you can configure it to perform this task. As for performing different tasks ...


1

Abandon server-side views completely and have the server side deliver only data (JSON, XML, whatever is convenient, but not HTML). The client side will be pure HTML and Javascript. That allows clients to present data any way they like without requiring any server side code. However, this statement is troublesome: their own ... client side validation ...


1

I don`t think storing error in models is good idea. Models are responsible for storing data not data and error. You breaking single responsibility principle. You should store erroros in ViewModels and populate them in controller.


0

In MVC the Model, is not just a DTO or set of Managers/Services it is meant to represent the concepts your application is modelling. You can think of this as the entire domain or the business logic including state and behaviours. Now given that we know that the purpose of the controller becomes a bit clearer. It's job is simply to translate commands onto the ...


1

Wait, they want "to implement their own [...] client side validation logic", but not server-side validation logic? This sounds as an important issue, security-wise. In the same way, having a bunch of views written by a third-party running on your server is out of question, since those views can contain harmful code. Now, if you need to let your customers ...


0

I find services really helpful to perform logic that may need to perform by more than one controller or that is just not specific enough to be part of the controller, besides the fact that it stops my controllers of getting too big and hard to read... I personally disagree with 'aaa' when he says that "model (where the bussiness logic happends)" since thats ...



Top 50 recent answers are included