I have a controller which is responsible for accepting JSON files and then processing the JSON files to do some user maintenance for our application. In user testing the file upload and processing works, but of course I would like to automate the process of testing the user maintenance in our testing. How can I upload a file to a control...
I just started using mocha and I find it annoying that when creating a new mock object, mocha expects it to be called exactly once. I have helper methods to generate my mocks and I'm doing something like this
my_mock = mock(HashOfParameters)
All of the parameters might not get called for each test method so it will raise an error:
...
A first look I thought erb accepts any Ruby code, but I've got this strange behaviour...
I have an array [of tags for my article], and I want to make a nice display for them. So I'm writing something like this:
<ul>
<% @post.tags.each do |item| %>
<li>item</li>
<% end %>
</ul>
The wrong output looks like this:
<ul>
<li>...
My background is .net 2.0 development using web forms. Before I was laid off I was looking into MVC which I enjoy very much. I have a few clients that I am consulting for and I now have to make a decision to either stay the course with ASP.NET MVC or switch to ruby rails or cakephp/codeigniter.
If I choose ASP.NET MVC I would have to up...
Hello,
I have the code:
<% form_for(@libation) do |f| %>
<%= f.radio_button :carbonated, true %> <%= f.label :carbonated, "Yes" %>
<%= f.radio_button :carbonated, false %> <%= f.label :carbonated, "No" %>
<% end %>
The carbonated column in db is tinyint. And when the above is run and I click "No" I get a big red box telling me:
1 err...
Hey guys,
I have a simple model "Match" that is supposed to save the bi-directional link between two objects (of the same kind).
class Match < ActiveRecord::Base
belongs_to :obj1, :class_name => "MyModel", :foreign_key => :obj1_id
belongs_to :obj2, :class_name => "MyModel", :foreign_key => :obj2_id
...
end
The problem I have is...
I want to remove a row from an HTML table generated by some Rails code and I'd like the other rows to "Slide Up" into the new position.
I'm kind of new to this and I'm sure I've probably made a simple mistake.
Here is the partial code to generate the table row:
<tr id="ride_<%=h ride.id %>">
<td><%=h ride.name %></td>
<td><%=h rid...
How would I go about accessing the Bundle-Fu plugin from this rake task?
I have tried everything out and nothing seems to work.
Note: assets_javascript & assets_css are both arrays of files that are pulled from a central location to keep this rake task and the view DRY.
desc "Generate cached css/js files"
task :asset_cache_genera...
Hello, I'm wondering what the best practice is for having redundant columns in a MySQL database. I'm wondering this because I have a User table in my database but I also want to be able to display many statistics about each individual user. These stats might include how many times a user has interacted with another model or how many me...
Hi! I'm trying to create some nice links over my website. I'm creating a search via tags just now, and I wonder if it is possible to create some nice routes like this:
http://myapp.com/search/a_very
http://myapp.com/search/nice_set
http://myapp.com/search/of_tags
or at least like this:
http://myapp.com/articles/search/a_very
http://m...
Trying to work with an existing database in rails. The below works just great in MySQL Console:
select title,blog_name from exp_weblog_titles JOIN exp_weblogs ON exp_weblog_titles.weblog_id = exp_weblogs.weblog_id LIMIT 1;
+------------+---------------+
| title | blog_name |
+------------+---------------+
| What We Do | chicag...
Hello,
There has to be a more efficient way in Rails of doing this:
<p>
<%= f.label :level %>
<%= f.radio_button :level, "0" %> <%= f.label :level, 0 %>
<%= f.radio_button :level, "1" %> <%= f.label :level, 1 %>
<%= f.radio_button :level, "2" %> <%= f.label :level, 2 %>
<%= f.radio_button :level, "3" %> <%= f.label ...
Is it faster to do multiple SQL finds on one table with different conditions or to get all the items from the table in an array and then separate them out that way? I realize I'm not explaining my question that well, so here is an example:
I want to pull records on posts and display them in categories based on when they were posted, sa...
I have items in my database schema that are an integer and are set to a specific number correlating to an item. For instance, a column named appointment_type can have the value set of 0=Unknown, 1=Medical, 3=Trial, etc... I don't want to use magic numbers in my rails code and would prefer an Enum like solution to make the code more ma...
I'm currently rewriting a website in Rails. I've written a model that maps the old static URLs to the new ones and in the application controller I'm trapping RoutingErrors to call a method that looks for a new URL that maps to the old one. This works perfectly well in the applicaion itself; if I visit http://localhost:3000/home.htm it wi...
I want to escape the inputs to this form so that when its enter in the database characters like .'* won't affect the update. How would I encode the characters to achieve the goal stated above.
<% form_for @post, :url => {:action => :createInnovation } do |form| %>
<fieldset>
<p> Title: <br/><%= form.text_field :title, :html => {...
I'm creating a personal site with Ruby on Rails. For the most part, RoR is the perfect tool, allowing for blog posts, comments, etc all rather easy.
However, I want to have a few pages that don't require any specific model. An 'About Me' page, for instance, is necessary, and yet doesn't warrant it's own model/controller. In addition, t...
Why can I access helper methods for one controller in the views for a different controller? Is there a way to disable this without hacking/patching Rails?
...
I have a legacy database that I'm working on getting ActiveRecord to work with. I've run into a problem with join tables. I have the following:
class TvShow < ActiveRecord::Base
set_table_name "tvshow"
set_primary_key "idShow"
end
class Episode < ActiveRecord::Base
set_table_name "episode"
set_primary_key "idEpisode"
end
...
I'm trying to write a simple OAuth consumer app in Rails. I'm using Authlogic for handling authentication and the Authlogic OAuth plugin to do the oauth thing.
The oauth plugin provides a couple of helpers to render the sign in button: oauth_login_button and oauth_register_button. Together with the Authlogic logics and the plugin's requ...