controller

web2py (and other MVC frameworks): How to execute base code on all controllers

In web2py, is there a way to have a piece of common code be executed before all controllers are called? For example, I want to add some code that will log client IPs to a log of requests to enable analysis. I could simply make the first line of all my controllers be something like response = RequestBase(request) but I'm curious to kno...

Adding my comments to the index view...Ruby on Rails

Ok...I am new to rails so this may be a stupid question but need help. I just watched and implemented Ryan Bates screencaset about setting up a blog. You can see it here http://media.rubyonrails.org/video/rails%5Fblog%5F2.mov. Here is the skinny: Two tables: Posts and Comments. Everything works great including the addition of comments v...

Controller specs in isolation mode and render :update

Hi folks, I am using RSpec for writing my controller tests/specs. I faced the problem, that the following code gets rendered: render :update do |page| page['middle_content'].replace_html :partial => "admin/pages/show" end Isolation mode is the default, isn't it? How can I fix this or am I doing something wrong? Here is for examp...

Rails - Too much logic in views?

I have an application used by several organizations and I want to check that users of one domain (a.domain.com) cannot edit users of another domain (b.domain.com). My question is where to put the logic, in a before filter or in the view? View: <% if @user.websites.detect {|website| website.url == request.host} %> render :partial => '...

Reverse order of display of blog entries and comments, Ruby on Rails

I am new to rails so could use some help here. I have followed several tutorials to create a blog with comments and even some of the AJAX bells and whistles and I am stuck on something that I hope is easy. The default display for both blogs and comments is to list the oldest first. How do I reverse that to show the most recent entries an...

Count records for Blog in Ruby on Rails - Easy Question

I am new to rails so sorry for the simple question. I have followed several tutorials and set up a blog with comments (even using a little AJAX - Ha proud of myself). I have done some customizing and right now I am trying to display in the index.html.erb a comment count that is a clickable link that takes to you the show.html.erb page. H...

MVC : Separate admin controllers

I was wandering if there is option to do the following If I call "admin/Category" - to call "CategoryAdminController" If I call "Category" - to call "CategoryController" It is very easy to do this via routing and custom controller factory. Here is the solution: // add route routes.Add(new Route("{culture}/admin/{controller}/{action}...

How do I dynamically change a controller in Zend Framework?

I'm halfway through a CMS where the URL is an SEO friendly name based on a page title. There is a need for one section to use a specific controller. So for example: test.com/page1 (uses index controller) test.com/page2 (uses index controller) test.com/page3 (uses different controller) test.com/page4 (uses index controller) I could add ...

ASP.NET MVC Controller Lifecycle

It's my understanding that the constructor for a controller is not called during each web request. Assuming this is true, what is the lifecycle of a controller? Is is "constructed" upon app start, then cached and invoked with the requestcontext injected into it with each web request? Just to be clear, I'm not asking how to emulate const...

uninitialized constant

Hi. I'm trying to do this tutorial-> http://netbeans.org/kb/docs/ruby/rapid-ruby-weblog.html BUT its giving me this error: NameError in PostsController#index uninitialized constant PostsController::Posts I don't know whats wrong ...

hpricot in netbeans

hi I am trying to use hpricot in JRuby. My problem is the following. If I have this code: #!ruby require 'hpricot' require 'open-uri' # load the RedHanded home page doc = Hpricot(open("http://redhanded.hobix.com/index.html")) where do I put it? Into my controller? Because its not accepting it there. And if I'm supposed to put it...

problem with login page ruby on rails

Hi I'm following a tutorial: http://visionmasterdesigns.com/tutorial-create-a-login-system-in-ruby-on-rails/ to create a login page when I try to do this part: def authenticate 02. #User.new(params[:userform]) will create a new object of User, retrieve values from the form and store it variable @user. 03. @user = User.ne...

mvc calling controller

I have a base controller, is it possible to know what the calling controller was called? ...

Load method from current Controller

Hi there! I have a problem that I can't figure out. I'm building a small framework (practice) and now I'm building the Validator library. everything works superb except when I trying to fix the "callback" rule. Callback rule is used when the dev need to use a rule that dosen't exists in the Validator lib.. Here's how I'm doing it. In...

How do I find out at runtime what area a controller is belong to in asp.net mvc?

Since this stuff is fair new I couldn't figure out any good reference on it. I want to use reflection to enumerate through all the controller in my application. This is not hard using reflection. But since area come into place. How do I know which area (if any) does a particular controller belong to? Maybe I am doing it wrong, maybe I ...

Passing Data from Controller to View to back to Controller to back to View

I'm new to ASP.NET MVC. After working with traditional ASP.NET model for so long, it's taking some time for me to get to understand this model. I am going through NerdDinner to understand how things work. So, I have an object that needs to be passed through couple of views. Similar to the article NerdDinner Step 6: ViewData and ViewM...

creating a controller in Rails

I'm trying to use the generate script to create a controller. I run the following command: > ruby script/generate controller Greeting and the controller seems to be generated no problem. Then I add a method called index to the GreetingController: class GreetingController < ApplicationController def index render :text => "<h1>We...

how can i call a controller action directly from a javascript function . .

I have the following code that shows a jquery ui dialog form with data for the user to enter: $("#dialog").dialog({ bgiframe: true, autoOpen: false, height: 300, modal: true, buttons: { 'Create an account': function() { var bValid = true; ...

pass values from the view to the controller ruby on rails

Hi This is my controller: def addcar @car = Car.new(params[:car]) render :action => "list" end this is my view: <%(@allcars).each do |cell|%> <p><%= link_to cell.to_s, :controller => "car", :action => "addcar", :car => cell.to_s %></p> <%end %> In the link_to statement I want to pass cell.to_s to the controller. ...

HandlerExceptionResolver for annotated controller.

I have annotated controller which contains several methinds mapped on urls. Like this: @Controller public class CategoryController { @RequestMapping(value = "/addCategories") public void addCategories(@RequestParam(value = "data") String jsonData) throws ParseException @RequestMapping(value = "/getNext") public void getNext(@RequestPa...