I am editing some code, and I see the following:
<% hook :login do %>
<% form_tag user_session_path do %>
<p>
<%= label :user_session, :login, 'Email Address' %><br />
<%= text_field :user_session, 'login' %>
</p>
<p>
<%= label :user_session, :password, 'Password' %><br />
<%= password_field :user_...
given the following schema
class User
has_many :page_views
#[id]
end
class Page
has_many :page_views
#[id]
end
class PageView
belongs_to :user
belongs_to :page
#[id, created_at, updated_at]
end
How can i query for a given page, all users most recent page views in order by created_at date. One row per user, showing only...
This is my form code.
<%= simple_form_for @user do |f|%>
<%= f.input :name %>
<%= f.button :submit %>
<% end %>
And this is the error I get :
compile error
/home/shreyas/apps/vaccidate/app/views/users/_form.html.erb:1: syntax error, unexpected ')'
... simple_form_for @user do |f|).to_s); @output_buffer.concat
...
I've recently dusted off an old Ruby on Rails project of mine. In the past, I've never had any problems getting all the tests to pass, but now there is one test that gives me the following error:
ActiveRecord::StatementInvalid: Mysql::Error: #HY000Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE)...
Am a newbie to rails ,
please let me know the way to comment out a single line and also to comment out
a block of lines in *.html.erb files.
...
Hello, I just installed paper_clip to allow user's to upload a profile pic which can be displayed easily with:
<%= image_tag @user.profile_pic.url %>
What I'm curious about now is how to handle user's that don't have a profile_pic uploaded.. How to show a standard site user image (generic)
Should I make a helper?
something like show...
Here is the truncate code I'm using:
<%= truncate(teammember.user.full_name, :length => 8)%>
teammember.user.full_name returns names like:
- Steve Jobs
- Larry Oracle
- James Bond
- Dhandar Kentavolv
Butall the truncate is doing is returning:
- Steve Jobs...
- Larry Oracle...
- James Bond...
- Dhandar Kentavolv...
The user.f...
In the controller, I'd like to do:
@options = { :obj_id => @obj.id, :obj2_id => @obj2.id }
And in the view:
<%=
remote_form_for(:model_object, :url => { :action => 'some_action' }) do |f|
@options.each { |k, v|
f.hidden_field(k, { :value => v })
}
}
%>
The code above currently will just output the string values of ...
Hi,
I'm working on a Newsfeed action. I have active friendships and i would like to find the posts only of those friendships to create the newsfeed.
This is the code i currently have:
@active_friendships = current_user.active_friendships
@posts = Post.where({ :user_id => [5,8,16] }).order("created_at DESC")
I don't know how to sen...
Hi,
I have been building a large scale rails app and it has come time to refactor it.
What tips can you offer me, or resources can you point me to? I am especially interested in making my database calls more efficient.
...
I came across a Gem that had a nice way of releasing certain features to a subset of your users. I believe it even had cucumber integration, so you could write tests for different sets of users. If someone knows the name, I would really appreciate it!
...
This post - http://www.ruby-forum.com/topic/51782 - seems to suggest a way of setting User.current_user in a before_filter in a controller and accessing User.current_user in models affected by that action. Is this perfectly thread-safe or are there security issues here? Seems like the correct approach would be to always pass in @current...
I'm still fairly new to rails but I've done file uploading before. I'm trying to implement very basic file uploading - nothing fancy, just upload the file, save it, and make a record of it. So here's my method for saving the file:
def self.save(upload,name)
directory='public/uploads'
ext=File.extname(upload.original_filename)
...
Hello all, I have the following model, Purchase, on my Rails app:
class Purchase < ActiveRecord::Base
[...]
belongs_to :payment, :validate => true
belongs_to :day, :foreign_key => :day_day, :primary_key => :day,
:counter_cache => true
[...]
end
And I have the Day model:
class Day < ActiveRecord::Base
[...]
has_many :...
This page I have been developing for my app has been working fine locally (using sqllite3) but when I push it to Heroku, which uses PostgreSQL I get this error:
NeighborhoodsController# (ActionView::Template::Error) "PGError: ERROR: column \"isupforconsideration\" does not exist\nLINE 1: ... \"photos\" WHERE (neighborhood = 52 AND is...
I'm using Ruby 1.8.7 with rubyGems 1.3.7 and mongrel 1.1.5 and keep getting the following error.
Error calling Dispatcher.dispatch #
There is supposed to be a patch to fix this at http://gist.github.com/471663 but for when I add this to config/initializers my app fails to route the address correctly giving me an error from /config/ini...
Hello, I have a model photo
which allows me to load URLs like
/photos
/photos/2
/photos/2/edit
Edit allows the user to change the image, but I want a different kind of edit for permission type stuff specific to the app I'm building, which would look like:
/photos/2/updatesettings
So in the photos controller I added "def updatese...
I have this rails find that i need to get the id as well but if i put the id in the :select wont it effect the query and is there another way to get the id
@past_requests = Request.find_all_by_artist(name, :conditions => ["showdate < ?", Time.now], :select => "distinct venue, showdate")
...
I am invoking a stored procedure (MySQL) from my model. This stored procedure returns a resultset, but i get this error...
Mysql2::Error: PROCEDURE
loqly.sp_venue_nearby_with_questions
can't return a result set in the given
context:....
Here's the rails code i use -
connection.select_all("call sp_some_proc()")
I have trie...
I'm wondering if there's a more direct way to get and record a users IP in the model itself. I've been doing it from the controller but I noticed using the rakismet gem it mentions doing everything from within the model, but not the IP specifically.
http://github.com/joshfrench/rakismet
Currently I'm doing this, just before I save fro...