If I upload files to my server and thus have clients/customers download these files. How may I restrict the access of the file?
Such as, if I upload a file to www.domain.com/files/download.zip
And if the user has correct permissions he can download the file, but what if the user knows the direct link to the file itself?
Cause I can ...
Desired Output:
<ul>
<li class="odd">stuff</li>
<li class="even">stuff</li>
<li class="odd">stuff</li>
<li class="even">stuff</li>
<li class="odd">stuff</li>
<li class="even">stuff</li>
<li class="odd">stuff</li>
<li class="even">stuff</li>
</ul>
CSS:
.odd {color:blue}
.even{color:red;}
In rails 3 is there a clean way to do...
Most of my views will required a wrapper of padding 10px,,, but a few will not...
I was thinking of doing something like this in the view controller:
respond_to do |format|
format.html { render :layout => true, :padding => 'false' }
And then in the application.html.erb have an IF to not add a padding class if :padding is false......
I'm trying to create a form that will show the id that the record is going to have, prior to hitting submit on the form. For example, if I have a form to create a new project, and the previous project was id 3, I want the new project form to autopopulate with 4, so that I know that it's going to be 4 before I submit the form.
Thanks for...
Hello,
I have the following in my def create controller:
@photo = current_user.photos.create(params[:photo].merge(:project_id => params[:project_id])
In my app photo records are valid if they have a project_id or not....
But I need my create statement not to error and work for both cases.
A. If there is a param project_id, insertit...
Is the following statement possible with Rails/Ruby? If so, how :)
IF XXX Equals At Least One (Var1, Var2, Var3)
...
Here's the current flow in my Rails App
1. User uses AJAX and creates a Photo record (stored in DB)
2. Then, the observer catches this and adds a record to the audit log
** That was all without a page refresh. The challenge I have now is that I need to have AJAX return a "news feed" item from the AuditLog created by the observer. It nee...
I'm a newbie to Rails.
Am currently using Rails 3.0 to develop my app.
How to handle a form in the public/index.html file which I'm planning to use as my Home page.
Usually a view's action buttons gets paired with the corresponding method of its controller.
But how to handle this in case the index file in public directory.
Thanks in Adv...
I can get one successful Open Flash Chart per view.
I'm now trying to support multiple Open Flash Charts per view but the source code shows that the ids for both generated divs are the same:
# javascript at top of view
<%= javascript_include_tag "swfobject.js", :cache => true %>
# view itself
<%= @graph.html_safe %> # html_safe is ne...
Hello, I'm using the Rails 3 plugin Will_Paginate and have been using the following tutorial to learn how to customize the pagination links:
http://thewebfellas.com/blog/2010/8/22/revisited-roll-your-own-pagination-links-with-will_paginate-and-rails-3/
My question is, how to make the pagination links more like GMAIL, example:
1 - 100...
Hi... Just started learning how to use paper_clip. I installed everything according the instructions and tried to upload an image (profile_pic)...
I got the error that I can't mass assign profile_pic...
so I added attr_accessible: :profile_pic
And that stopped that error. What I'm curious about is I don't have a 'profile_pic' column i...
I get a NoMethodError: undefined method `get_best_compatible' for nil:NilClass in mail
`from /usr/lib/ruby/gems/1.8/gems/activesupport-3.0.0/lib/active_support/whiny_nil.rb:48:in 'method_missing'from /usr/lib/ruby/gems/1.8/gems/mail-2.2.7/lib/mail/body.rb:143:in 'get_best_encoding' from /usr/lib/ruby/gems/1.8/gems/mail2.2.7/lib/mail/mes...
I have a Rail3 app with paper_clip, with the intent to store data on S3.
In the app, Users belong to an instance.
I would like the data stored across all the models per instance. And would like to prevent a user for Instance A from accessing, or being able to load data from Instance B.
What's the best way to handle this? thanks
...
I am following Ryan Bates' railscast on Sortable Table Columns and I have successfully gotten a column to sort ascending and descending.
My table is more complex than in the Railscast because I have columns from different tables.
# controller
@cars = Car.find(:all).order(sort_column + " " + sort_direction).includes(:manufacturers)
#v...
Hi there,
I have two models and controllers:
Snippets, and Tags.
There is a belongs_to relationship, with tags belonging to snippets. This works well, I have a text field which creates a new tag associated with the snippet when the user submits a snippet.
I want to be able to have a text field which, when submitted to a function (in t...
I've been upgrading my app from Rails 2.3.8 to Rails 3.
After getting all the basic stuff done (configs, routes, and the new AR API, replacing Authlogic with Devise) and getting some mostly static pages to show up fine I get an error in the rest of my site:
You have a nil object when you didn't expect it!
You might have expected an ins...
It seems that most of Rails 3, Ruby 1.9.2 can be used, but when it is sqlite3-ruby, or mysql2 gems, then it can't compile, (missing mkmf?) and the latest Xcode is needed. But the latest Xcode is for Snow Leopard only. So looks like the Macbook needs to be upgraded to Snow Leopard before Rails 3 can be used?
...
I need to store dependencies in a DAG. (We're mapping a new school curriculum at a very fine grained level)
We're using rails 3
Considerations
Wider than it is deep
Very large
I estimate 5-10 links per node. As the system grows this will increase.
Many reads, few writes
most common are lookups:
dependencies of first and secon...
I'm getting the following error:
NameError (undefined local variable or method `acts_as_authentic' for #<Class:0x1037e6310>):
app/models/user.rb:2
app/controllers/user_controller.rb:3:in `new'
I'm using Rails 3.0.0, with Ruby 1.8.7. Authlogic is in my Gemfile as follows:
gem 'authlogic', :git => "git://github.com/binarylogic/auth...
Give a model.created_at
I've been able to use:
<%="#{time_ago_in_words(model.created_at)} ago "%>
What is the helper to output something like
Oct 8
Sep 23
Aug 31
Jul 11
Bonus points, if it outputs like above, but for any records that were created today (not 24hrs ago but today). it shows the time, example:
4:31pm
1:20pm
9:31am...