I find a common issue in my RESTful Rails apps controllers that respond to multiple formats (HTML, XML, etc). The issue is that, for any given method (INDEX, CREATE, NEW, EDIT, SHOW, UPDATE, or DESTROY) I want to restrict access to admin users for 1 format, but not others. Of course I already have a "before_filter :admin_required" for ...
Basically, I want an array of ids from the database.
Some background:
I'm rendering a list of objets (foos) to the user with a checkbox.
If the user checks the box a row is create in a different table (bar)
when rendering the foo list + checkbox I want to check if the unique id any given foo already exists in the bar id array.
I ...
Hi ,
i am new to ROR
i am having an api code for blogs in my application . this includes the function create,show,update .
I am trying to write sample Api code in Ruby for this. How to write this ??
Please give suggestions.
My Create code is
def create
@blogpost = Blogpost.new(params[:blogpost])
@blogpost.user = current_user
...
So I have a Wordpress site and I also have an Rails based Application Process for people to sign up to come to our organization. Is there a way I can have a login form on the Wordpress site somewhere and when they click login, it logs them in to the rails app? I'm using Restful Authentication on my rails app.
Thanks so much!
...
I am upgrading an application to Rails 3.0.0 and am wondering if the standard method for adding SSL has changed (I vaguely remember demos indicating the router could now handle SSL, though I'm not sure if it was just for demonstration purposes). I currently use the "ssl_requirement" gem, however it gives:
DEPRECATION WARNING: Using #...
I have a file containing a helper class something like this:
app/classes/myfile.rb
Module mymodule
class myclass
# blah blah
end
end
I want to use this class in a controller, so I wrote something like this:
require 'myfile'
class MyController < ApplicationController
include mymodule
def index
mymodule::myclass.n...
What's the main difference between:
rake gems:install
rake gems:unpack
I had a problem with it telling me I was missing these gems. I did the rake gems:install. Then I thought I had installed the gems. But it said again , I was missing gems. After I did rake gems:unpack. It fixed the problem. Why is that?
####com@#.com [~/rails_app...
Hello,
I have this kind of relation:
class Article < ActiveRecord::Base
has_many :comments
end
class Comment < ActiveRecord::Base
belongs_to :article
attr_protected :article_id
end
The default scenario inside controllers looks like:
@article = Article.create(:title => "foobar")
@comment = @article.comments.create(:content => ...
I am currently using hostmonster.com for hosting rails application. Does anyone use them? I notice that they are a bit slow with rails applications. Why is that? Does rails really use that much in terms of system resources? Has anyone deployed using scripts, capistrano on hostmonster.com?
This is my current .htaccess script. Could writi...
when I do this
ip = request.env['REMOTE_ADDR']
I get the client's IP address it it. But what if I want to validate whether the value in the variable is really an IP?
How do I do that?
Please help.
Thanks in advance. And sorry if this question is repeated, I didn't take the effort of finding it...
...
I'm using acts_as_versioned for versioning a model Post. The plugin basically allows versioning a model by using an additional table that stores the different versions of each post.
In my tests, I have defined some posts in posts.yml. However, the fixtures with the initial versions for this posts (in file posts_versions.yml) have to be ...
Hi, my mac just broke and I had to migrate to an Ubuntu machine. I am working on an app that is already on production on an Ubuntu machine as well.
I cloned this app into my new machine and all the view helpers seems to go missing, btw I am ussing HAML.
I ran my specs and I am getting tons of :
undefined method url_for for #
und...
Hi All,
my server is having rack gems as:
rack (1.2.1, 1.1.0, 1.0.1, 1.0.0)
when i run the following command in my project/vendor/gems folder:
gem unpack rack-1.0.0
It shows the following error message:
Error: Gem 'rack-1.0.0' not installed.
Any idea on this??
Thanks,
Saurabh
...
hi,
I have a page which shows a Google map. I'd like to use Javascript to fetch several points from my database and place them as markers on the map. So the flow is:
Javascript calls a Rails action with parameters.
Rails queries the database.
Rails returns the response.
Javascript updates the page (Rails can't do this since it must be...
Is there a way in Devise 1.0, the library for Rails 2.3, to redirect to a specific URL and not root_url after logging in?
EDIT: forgot to mention it's Devise 1.0
...
Is there any solution to solve the problem of rake task rails:upgrade:check on windows ?
...
I am running rails 3.0.0, rspec-rails 2.0.0.beta.20, webrat 0.7.2.beta.1, cucumber-rails 0.3.2
I have this scenario:
Scenario:
Given I am on the new account page
And I fill in "Name" with "John Doe"
When I press "Create"
Then I should be on the access page
When I run it I get:
expected: "/access",
got: "/accounts"
Like its ...
Hello, guys.
Do you remember any gems/plugins out there to support an affiliate (referral, partner) like system?
e.g the 37signals affiliate program
Any help/links would be appreciated.
...
Hi,
I would like to implement a 'flag as inappropriate/abusive' notification system for my app, whereby users can click an icon or link if they think a post/comment is inappropriate, and a notification email is then sent to the site admin. Are there any gems/plugins for this kind of functionality (Rails 3)? Or if I need to roll my own, ...
Okay, I have a few different of ideas of how I would achieve this, but thought I would ask here in case someone has a better solution.
I have a SessionsController that has a login view and a widget_login view. I was wondering how to go about determining which view to render in the new action of SessionsController.
Right now, everythin...