partials

Rails render of partial and layout in controller

百般思念 提交于 2020-01-11 04:38:13
问题 I am overriding the create action of the devise Registrations Controller. I have two forms for signup, individual or company, a company has a field called company_form set to true that differentiates the two forms. Upon form validation I would like the correct form to render (previously it was going back to the default form no matter what form i was using). I am having an issue where just the partial is being rendered (obvious as i am only rendering the partial), but I need the layouts

Why aren't instance variables defined in a controller's methods available in the corresponding partials?

扶醉桌前 提交于 2020-01-06 19:26:26
问题 For example, given a basic controller such as: class PostsController < ApplicationController def index @post = Post.all end The instance variable @post is available in the view posts/index.html.erb but not the partial posts/_index.html.erb My primary questions are: Why is this? and How can I define a method for a partial in a controller to for example, pass an instance variable? On a more specific note: I ask this because the way I am rendering data in a separate, primary view welcome/index

scala currying/partials to build function filter list

你。 提交于 2020-01-04 09:06:10
问题 Given the following code: case class Config( addThree: Boolean = true, halve: Boolean = true, timesFive: Boolean = true ) def doOps(num: Integer, config: Config): Integer = { var result: Integer = num if ( config.addThree ) { result += 3 } if ( config.halve ) { result /= 2 } if ( config.timesFive ) { result *= 5 } result } val config = Config(true,false,true) println( doOps(20, config) ) println( doOps(10, config) ) I'd like to replace the ugly doOps method with a more efficient and idiomatic

scala currying/partials to build function filter list

纵然是瞬间 提交于 2020-01-04 09:06:10
问题 Given the following code: case class Config( addThree: Boolean = true, halve: Boolean = true, timesFive: Boolean = true ) def doOps(num: Integer, config: Config): Integer = { var result: Integer = num if ( config.addThree ) { result += 3 } if ( config.halve ) { result /= 2 } if ( config.timesFive ) { result *= 5 } result } val config = Config(true,false,true) println( doOps(20, config) ) println( doOps(10, config) ) I'd like to replace the ugly doOps method with a more efficient and idiomatic

rspec view stubs and partials

不打扰是莪最后的温柔 提交于 2020-01-02 05:43:07
问题 I'm testing a view with RSpec (2.12 on Rails 3.2.8). I'm using CanCan to conditionally display certain elements on a page. This requires a controller method 'current_user'. In some of my specs I've been able to stub out current_user, eg. controller.stub(:current_user).and_return(etc) or view.stub.etc . This works for some of my specs. But I've got a couple where it's not working and I don't understand why. The two specs where it's not working test a view, which calls down into a partial, and

CakePHP 3 and partial View update via Ajax - How it should be done?

蹲街弑〆低调 提交于 2019-12-25 08:48:10
问题 One more time I have bumped into the problem how partial view upadtes via ajax should be done in CakePHP3. From my point of view, there are 3 ways of doing this: Render required part of the view in dedicated controller action and simply inject the HTML. Create dedicated template (*.ctp) file for every ajax action, render it like any other action but without the main layout and inject the HTML (kind of variant 1 but with separated VC logic). Return only required data as an ajax response (eg.

rails namespace routes and controller

雨燕双飞 提交于 2019-12-25 05:46:08
问题 i just can not figure out the best way to handle the routes / controller with the following namespace. i´d just like to have the following setup: .../manage/rooms/ ( <%= @ rooms.number_of_rooms%>, <%= @ rooms.title %> ) .../manage/fuu/ ( <%= @ fuu.id %>...) ..manage/foo/ ... i know this is done by routes.rb namespace :manage do resources :rooms, :fuu, :foo end and under ... controller/manage/rooms_controller.rb and fuu_controller.rb and foo... example: class Manage::RoomsController <

undefined method `fragment_for' for nil:NilClass on render partial with cache

人盡茶涼 提交于 2019-12-24 07:11:46
问题 I have this piece of code in a partial on some code for rails 2.3.14: <% cache "some_partial_#{some_id}" do %> .... <% end %> Works fine when rendering it in a view but I get: undefined method `fragment_for' for nil:NilClass when I try to do this in a model: ActionView::Base.new("app/views").render(:partial => "home/temp"} I can see the issue occuring in actionpack-2.3.14/lib/action_view/helpers/cache_helper.rb:35 def cache(name = {}, options = nil, &block) @controller.fragment_for(output

Rspec2 partial view gives nil:NilClass. Why?

爱⌒轻易说出口 提交于 2019-12-23 05:11:20
问题 I am trying to get going with development of view components with Rspec2 and Rails3. However, I make the following observation, and I don't understand what is going on, and how to fix this. In my spec I define: describe "main/index.html.erb" do it "displays a photo url in products partial" do assign(:designs, [stub_model(Design, :name => "test", :photo => "photo_url")]) render rendered.should contain("photo_url") end end When I run: rspec spec/view/main_spec.rb I get this error: 1) main/index

Multiple Layers of Deep Linking in AngularJS

让人想犯罪 __ 提交于 2019-12-22 20:52:21
问题 I am attempting to place multiple controllers within my template partials with AngularJS- The problem I am encountering is that of the first layer, direct-linking to these sub-controllers and their related snippets. An example would be a management page for user accounts, say I am on a user-list and wanted to change a user from the list's password, I click on their change-password button, and want to redirect the user to #/ManageUsers/ChangePassword/?UserID=<uid here> rather than #