0
votes
2answers
113 views

passing a paperclip image from the controller to a view in rails

I have a model that has an image attached to it that I want to be passed through a controller into a view. This is the way I have tried myself but it does not work: Model: class CustomForm < ...
2
votes
4answers
1k views

Instance Variables in Rails Model

I want to initialize an instance variable within my Rails model that will hold an array and I want to access this variable in other methods within my model. I tried this: class Participant < ...
0
votes
1answer
56 views

Ruby / Rails: Assigning values to an instance variable

What is the easiest way to assign attribute values to the (model) instance variable, when these attribute values are located in a big hash (session[:some_big_hash]) that contains the usual model ...
0
votes
1answer
39 views

Passing instance variables into API in rails

I'm trying to pass in some instance variables to call an API with that specific object's attributes. A user fills in their car details (make, model, and year) which creates an offer object. That is ...
-1
votes
3answers
67 views

How do i append some value to an instance variable in ruby on rails?

Here's what I am trying to do in my home controller: def view @product= Product.find(params[:id]) rand_price = rand(202- @product.price.to_i) + @product.price.to_i old_price = rand_price ...
0
votes
1answer
66 views

Link_to and Ajax request Rails

Hopefully I can explain this so people can understand what i am trying to achieve. Currently I have multiple posts being created and they are shown at this url for public view /tynewyddnews as ...
1
vote
3answers
288 views

Ruby and Rails: Metaprogramming variables to become class methods

I'm creating a model called Configuration and I have the following code and I want to make it more dynamic by using metaprogramming. In a table on the database for Configuration model I have the ...
0
votes
2answers
56 views

ruby on rails instance variable and if elsif

In my Show View I have: <div class="reviews" > <% @reviews.each do |review| %> <%= review_block review %> <% end %> </div> In my Controller I have: def ...
0
votes
1answer
64 views

@controller instance variable in Rspec

Just curious. How is the @controller instance variable inside the controller specs being instantiated? And where?
0
votes
2answers
23 views

Declarative Auth blocking instance variables

I'm using declarative authorization in my rails app, and I have the following controller: class OrganizationsController < ApplicationController filter_resource_access attribute_check: true ...
1
vote
1answer
358 views

undefined method `each' for nil:NilClass?

I want to dynamically create checkboxes with the users in the database, which shall be possible to choose (one or many). However, I am apparently doing something wrong because the code below gives me ...
0
votes
4answers
161 views

Instance variable not being recognized by its view

Can anyone think of a reason why an instance variable declared in the controller would not be recognized by its view? Controller looks something like this: class UsersController < ...
-1
votes
1answer
50 views

Ruby deduct from instance variable same values from other

I have two instance values: @a, and @b, there are hash-like.... (will explain on pseudo examples) For example in @a i have: *Field1 | Field2 | Field3* CONTITECH | CT942K1 | 123 CONTITECH | CT722K1 | ...
1
vote
2answers
134 views

Hidden instance variables in before_filter method

Is it a good practice to hide instance variable initialization in private methods? For example, I have a user controller with some actions: class UsersController < ApplicationController ...
0
votes
4answers
49 views

Why does my view code use both an instance variable and a local variable?

I am looking at a book example. In the view section for a Products model, I see some code like this: <table> <% @products.each do |product| %> <tr class="<%= cycle ...

1 2 3 4 5 6
15 30 50 per page