controller

Why are my links not working for my ruby on rails site? Links stay on same page when clicked on

时光毁灭记忆、已成空白 提交于 2019-12-03 00:11:12
问题 My links aren't working for my ruby on rails site. When I click the link the site stays on the same page. I'm following code from a book called: "RailsSpace: Building a social networking site with ruby on rails" By Michael Hartl. The book is available free for download you can follow the code for yourself, its on pages 55-56 starting under the title "adding navigation". Here is a link to the ebook. Thanks for your help. I tried googling the "link_to" function and changing the format, all it

Spring Boot - redirect to a different controller method

帅比萌擦擦* 提交于 2019-12-02 22:53:34
I am very new to Spring Boot. I am creating a very basic application with SpringBoot and Thymeleaf. In the controller I have 2 methods as follows: Method1 - This method displays all the data from the database: @RequestMapping("/showData") public String showData(Model model) { model.addAttribute("Data", dataRepo.findAll()); return "show_data"; } Method2 - This method adds data to the database: @RequestMapping(value = "/addData", method = RequestMethod.POST) public String addData(@Valid Data data, BindingResult bindingResult, Model model) { if (bindingResult.hasErrors()) { return "add_data"; }

ActiveRecord::RecordNotFound — Couldn't find User without an ID

♀尐吖头ヾ 提交于 2019-12-02 22:23:01
Please see UPDATES at the bottom of the question... For reference, this problem evolved out of some fixes I made based on a previous problem I was having here: Associating Two Models in Rails (user and profile) I'm building an app that has a user model and a profile model. I want to associate these models such that: - After the user creates an account, he is automatically sent to the "create profile" page, and the profile he creates is connected to only that particular user. - Only the user who owns the profile can edit it. I generated the user model using nifty_generators. When the user hits

Upload Photo To MVC 4 Applications

亡梦爱人 提交于 2019-12-02 19:48:05
I'm trying to create a controller to upload photos in my MVC4 application. But I keep getting this error. The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or a non-white space character among the padding characters. PhotosController.cs public class PhotoController : Controller { public ActionResult Index() { using (var ctx = new BlogContext()) { return View(ctx.Photos.AsEnumerable()); } } public ActionResult Upload() { return View(new Photo()); } [HttpPost] public ActionResult Upload(PhotoViewModel model) { var photo = Mapper.Map

twitter bootstrap modal with ruby on rails

断了今生、忘了曾经 提交于 2019-12-02 19:40:55
I have run into a bit of a problem and a head scratcher, as I'm not sure whether what I want to do is even possible with RoR. A bit of background info: I have an app with several controllers... and would like to work with 2 of them for this modal example. The first is a users_controller and the other is a recommendations_controller. Here is what I'm trying to do: In the user index view I have a lists of posts. Each post has a recommend button. If a user clicks it he/she is sent to the recommendation index page, and can search and find a user he/she would like to share the post with. The reason

What is the proper way to test 'create' controller actions?

你离开我真会死。 提交于 2019-12-02 19:39:43
I am using Ruby on Rails 3.2.2, Rspec 2.9.0 and RspecRails 2.9.0. I would like to test the create controller action but I don't know how to make that the "right"/"proper" way. I "scaffolded" model, controller, view, ... files, so in those files I have the common code generated by Ruby on Rails generators; in my spec file I have: it "assigns @article" do new_article = FactoryGirl.build(:article) Article.should_receive(:new).and_return(new_article) post :create assigns[:article].should eq(new_article) end Maybe, ( note : the above code is almost the same as that I use to test the new controller

How to switch controller values from ng-include in angularjs?

不羁岁月 提交于 2019-12-02 18:55:05
问题 I am using angularjs. i have one header.html and I have merged that html page into another html using ng-include. Also, I have one dropdown list in header.html and I want the selected value (from dropdown) list to be displayed. How can I do this? header.html <html ng-app="app" > <head> <script src="assets/js/jquery-2.1.4.min.js"></script> <script src="controller/headerctrl.js"></script> </head> <body ng-controller="headerctrl"> <select id="valueid" class="form-control" required typeof="text"

Why does Rails create a controller for every request?

泪湿孤枕 提交于 2019-12-02 18:10:57
From my previous question I understood that Rails creates a controller instance for every request. My question is, because this subject is related to the design of the project I'm working on: Why does Rails creates a new instance of class SomeController < ApplicationController; end to process every incoming request? Why not just create singleton object and forward requests to this one? This seems more efficient as we won't waste resources on allocating and cleaning objects for request? The overhead of instantiating a new controller instance is insignificant, and it means there is no

extjs - how correctly call a controller method from another controller or closure

删除回忆录丶 提交于 2019-12-02 17:40:41
I'm new to extjs and I'm using the MVC architecture. When my application references a method of a controller, I do it that way (in MyApp.Application ): Mb.app.getController('Main').myMethod(); It is already long, but I think this is the way to do. When a controller calls it's own method in a closure, I was led to use this code (in MyApp.controller.Main : controllerMethodOne: function(){ Ext.Ajax.request({ url: ..., params: ..., success: (function(response){ list = Ext.JSON.decode(response.responseText); list.forEach(function(item){ storeMenu.add( Ext.create('Ext.menu.Item', { text: item.text,

ExecuteCore() in base class not fired in MVC 4 beta

痴心易碎 提交于 2019-12-02 17:09:05
I have a base controller class: And all my other controller inherits this BaseClass like this All this works great in MVC3 (test again today, it really works) but it seems that the ExecuteCore in BaseController is not fired any more in MVC 4 beta. Any idea? Or Anything huge has changed under the hood? Thanks very much. public class BaseController : Controller { private string _myData; public string MyData { get { return _myData; } } protected override void ExecuteCore() { _myData = "I am doing something"; base.ExecuteCore(); } } public class HomeController : BaseController { public