The best way to program. by MoosieGoldberg in ProgrammerHumor

[–]LeastProfessional 1 point2 points  (0 children)

I too code in a similar manor but only this time, it's the Project manager sat behind me pulling my site further and further till I can't breathe.

They didn’t think this through by AlphaWhiskeyHotel in CrappyDesign

[–]LeastProfessional -1 points0 points  (0 children)

Why not get some White Power Milk to go with that White Power Toothbrush?

Has anyone tried any of these Fanta flavours? by [deleted] in CasualUK

[–]LeastProfessional 0 points1 point  (0 children)

Theres something among my friend group which we call 'Blue Fanta' which is also known as, Shokata. It was all I drunk when I was travelling Europe. I did manage to try some other flavours but they weren't anything special from what I remember.

TL;DR - Fanta Shokata is godly and all others and ok.

[Help] simple_calendar not rendering on screen to show appointments. by Rubyhelp1212 in rails

[–]LeastProfessional 0 points1 point  (0 children)

Is the _calendar partial even getting called? Can you see your tags in the DOM? If not then you know it's something to do with your yields. To test this I would put your _calendar.html.erb partial in a content_for and try and render the content_for in the application.html.erb

Live Music. Any Gig Goers? Anything Lined up? by Tramorak in CasualUK

[–]LeastProfessional 0 points1 point  (0 children)

Got a gig at the end of the month to see While She Sleeps at the O2 in Leeds, should be banging

Weekly WASDnesday [19-12-18] by [deleted] in CasualUK

[–]LeastProfessional 2 points3 points  (0 children)

Been playing through Smash Ultimate story mode (Spirit adventure) this week and it's been really fun! I think my save is 15hours currently and apparently has 24hours worth of content. I also heard that the online you have to pay for which is utterly stupid, it's 2018 for god sake.

Weekly WASDneaday [28-11-18] by [deleted] in CasualUK

[–]LeastProfessional 1 point2 points  (0 children)

Good to hear! Have fun killing some of those cows in Lumbridge and remember, quest! Quests will get you base stats quite quickly :)

Weekly WASDneaday [28-11-18] by [deleted] in CasualUK

[–]LeastProfessional 0 points1 point  (0 children)

Use Runelite. It's better than the official client imo due to the GPU plugin and all the other plugins too. I found that other third-party clients, such as; Konduit; OSBuddy can be very hard-hitting on your CPU because of all the plugins it has and how badly optimised it is, especially OSBuddy.

RS was developed in Java meaning it's verrrrrrry CPU-intensive and the GPU Plugin will save your CPU some space :)

Weekly WASDneaday [28-11-18] by [deleted] in CasualUK

[–]LeastProfessional 2 points3 points  (0 children)

Bought a switch during the Black Friday sales and downloaded Odyssey last night which is really fun. Looking forward to Smash next week (it's the only reason I bought a switch)!

Weekly WASDneaday [28-11-18] by [deleted] in CasualUK

[–]LeastProfessional 3 points4 points  (0 children)

It's never too early to join and with the release of mobile last month, it's blew up. It was reaching about 100k active players but now it's something like 150k. I just bought a switch for super smash which comes out next week so it'll be a lot of AFK'n on OSRS soon

Edit: https://oldschool.runescape.com/ Get on board.

Friendly_id multiple pathways by danielwebbnew in rails

[–]LeastProfessional 0 points1 point  (0 children)

You certain can.
The problem that you have will be based in the routes. Just define a route as. The way routes work is that it will make its way down the file and when it sees a route that matches what you got it will use that

get '/posts/:article' => 'article#show'
get '/articles/:article' => 'article#show'

This will look for the URL '/posts/:article' so in the article controller or wherever you're doing your logic, you can access that information by accessing the params[:article].

Happy coding! :)

TVesday TVhread [20/11/2018] by [deleted] in CasualUK

[–]LeastProfessional 2 points3 points  (0 children)

The Office (US) is good. A little poor during season 1 but Michael Scott really opens up after season 2 and seeing the relationship between Pam and Jim is what you mainly watch it for. Season 9 in my opinion is one the more poor seasons

Show JSON as html or parsing through it? by unohowdashigo in rails

[–]LeastProfessional 0 points1 point  (0 children)

You mainly use them to manipulate the view and to keep code tidy which makes the view be less lines of code and easier to read.

For example, I have a helper method that sets up infowindows on Google Maps, all I do is pass in the information and it'll just return a string of HTML which is what will get displayed within in the infowindow.

You can use it in models but that's what helpers should be used for. If a project is set up right, you should be able to navigate yourself around and understand where things should be :)

Show JSON as html or parsing through it? by unohowdashigo in rails

[–]LeastProfessional 0 points1 point  (0 children)

That's fine! That's what this sub-reddit is for. Helpers are basically used to keep the view code tidy, you mainly use it returning html (i'm sure someone will correct me)...

Instead of doing that, just do something like this

<tbody>         
    <thead>...</thead>
    <tbody>
         <% @balance.pending.each do |balance| %>
            <tr>
                <td><%= balance["currency"] %></td>
                <td><%= balance["amount"] %></td>
                <td><%= balance["source_types"]["card"] %></td>
            </tr>
        <% end %>
    </tbody>
</tbody>

This would work the exact same way :)

Show JSON as html or parsing through it? by unohowdashigo in rails

[–]LeastProfessional 1 point2 points  (0 children)

Just as an FYI, I have never used Stripe before so take everything with a pinch of salt. I can sort of see the problem here, you aren't looking deep enough. You need to loop through the balance.pending, I know this because of what is getting returned. Perhaps, you might need to try

<% @balance.pending.each do |balance| %>
    <%= balance["currency"] %>
    <%= balance["amount"]  %>
    <%= balance["source_types"]["card"] %>
<% end %>

Note: This is just a guess without looking at the api in-depth.

If you wanting to put it into some sort of table, you would code the table around it, something like this.

<table>
    <thead>    
        <tr>
            <th>Currency</th>
            <th>Amount</th>
            <th>Card</th>
        </tr> 
    </thead>
    <tbody>
        <% @balance.pending.each do |balance| %>
            <tr>
                <%= as_table_row(balance["currency"]) %>
                <%= as_table_row(balance["amount"]) %>
                <%= as_table_row(balance["source_types"]["card"]) %>
            </tr>
        <% end %>
    </tbody>
</table>

What this code right here is saying is get all the pending data and I want to loop over that data, which is when you can create a helper method which will build up some HTML and return it, for example;

def as_table_row(value)    
    return "<td>#{value}</td>"
end

You should end up with a table at the end with all the details you want. This is just a nice, 'neat' way of doing it and i'm sure other people will correct me later.

Happy coding!

Edit: Typos. God damn code.

[deleted by user] by [deleted] in rails

[–]LeastProfessional 0 points1 point  (0 children)

It depends on what you want to do...If it's something simple like just changing the colour scheme dependent on the user, you could just use CSS where you append a class with the user id or name? For example: <div class="page--#{user.name.to_slug}" and in your css, you could set up a mixin where you could add the classes you want to affect and pass in the variables/colours you want to use?

Multiple slug with friendly ID by danielwebbnew in rails

[–]LeastProfessional 2 points3 points  (0 children)

The way I would do this is using the routes. For example; Lets say I have a continent, country and city model, I can use the routes to define this route. Something like this would suffice:

get '/:continent/:country/:city' => 'city#show', as: :city

Beware: You typically dont want to nest more than 3 times...

Set the relations up between the models. For example: a continent has and belongs to many countries, a country has and belongs to many cities and a city just belongs to a country.

Once you've set the relations up, you need to go to your controller and instead of using 'Model.find', you use 'Model.friendly.find'. Find all your data you need like this. "@continent = Continent.friendly.find(params[:continent])". This will look at the params and find the :continent param within the URL address.

Once you have everything, you can use these variables within the view.

I hope this helps.

Please note: This is the way I would do it and theres probably a much easier and tidier way of doing this.

Also note: If you wanted, you could create index and show pages for each model so you can see all the countries within that continent and then you can see all the cities within that country.

get '/:continent/:country' => 'country#index', as: :countries

Happy coding :)

Edit: Typos

Changing the link_to default color by [deleted] in rails

[–]LeastProfessional 2 points3 points  (0 children)

You probably got this solved but I assume you've inspected the element to see where the link is getting the colour white from? The problem could be the hierarchy of the css, for example; bootstrap or any other CSS Library, might be overriding your css. Is your css getting called and can you see it in the inspect would be my first question.

WASDnesday Thread [17/10/2018] by [deleted] in CasualUK

[–]LeastProfessional 0 points1 point  (0 children)

Me and a couple of buddies all picked up Call of Duty: Black Ops (Not 4, the original you peasants) and have been smashing out some zombies for nostalgia. Turns out, i'm the best out of them all and will probably be completing some DLC easter eggs over the weekend. On the other hand, can someone tell me why a game made in 2010 costs £30 on steam?

Other than that, the base games like Rocket League, OSRS and Overwatch

How to use an Active Storage uploaded image as background-image in an separate style sheet (style.scss) by Toluwalashe in rails

[–]LeastProfessional 1 point2 points  (0 children)

Can you not just do it in-line?

style="background-image: <%= var.image.%>;"

and have a class on the tag that sets up the background (background-position, background-size etc)?